PDA

View Full Version : tinkering - firing event on tree dbl click


tsquires
Sep 28th, 2004, 06:53 PM
Hi,

I'm trying to tinker with the standalone PetClinic client sample and am at a loss as to where to start - forgive me if this is a dumb question.

I would like a double-click on a name in the owners tree to fire a global "propertiesCommand" similar to what happens when you hit 'ALT-Enter' with an owner selected.

In broad brush-strokes, what should I do to acheive that?

Thanks in advance,
Trevor

oliverhutchison
Sep 28th, 2004, 09:18 PM
1) Add a mouse listener to the tree.
2) On double click event lookup the properties command
3) If command is enabled call execute


tree.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2
&& e.getButton() == MouseEvent.BUTTON1) {
ActionCommand command = getCommandManager()
.getActionCommand(GlobalCommandIds.PROPERTIES);
if (command.isEnabled()) {
command.execute();
}
}
}
});



Ollie

tsquires
Sep 29th, 2004, 11:45 AM
Thanks Ollie, that clears it up.

Trevor