Hi, Klaus,
 
I think you might want to look into the source code of
javax.swing.plaf.basic.BasicTreeUI class.
 
It defines a MouseHandler inner-class to handle the mouse
click on the Tree. The mouseHandler calls a protected method
to check if the mouse event is a "toggle" event.
 
/**
 * The following code was copied straightly from the
 * BasicTreeUI.java source code
 */
 
/**
 * Returning true indicates the row under the mouse should be toggled
 * based on the event. This is invoked after checkForClickInExpandControl,
 * implying the location is not in the expand (toggle) control
 */
protected boolean isToggleEvent(MouseEvent event) {
   if(!SwingUtilities.isLeftMouseButton(event)) {
       return false;
   }
 
   // NOTE: This will be enabled in a future release.
   int           clickCount = 2;//tree.getToggleClickCount();
 
   if(clickCount <= 0) {
       return false;
   }
   return (event.getClickCount() == clickCount);
}
 
I guess if you override this method in your customized UI class,
so it return false even if it is double click, it might work.
 
I never tried it before, but hope it helps.
 
Mingjian Song
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of [EMAIL PROTECTED]
Sent: Monday, March 18, 2002 7:30 AM
To: [EMAIL PROTECTED]
Subject: JTree doubleclick


Hi,

I need a JTree which open a Dialog Window if someone makes a doubleclick on a node.
It is no big problem and I made it work, but my problem is, that the Tree does expand/collapse each time someone doubleclicks on it. (This is default behaviour)

Is there a way to turn this behaviour off? I dont want to turn off all expand/collapse events, because I must be able to expand / collapse by clicking on the '+/- ' signs in front of a node to expand/collapse this node, ('+/-' look so in windows Look & Feel only).

Anyone understands my english and can help me?

Klaus Krieger

Reply via email to