File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes jtable would like to handle both single click and double click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "jtable would like to handle both single click and double click" Watch "jtable would like to handle both single click and double click" New topic
Author

jtable would like to handle both single click and double click

steve labar
Ranch Hand

Joined: Sep 10, 2008
Posts: 55
I have a jtable where i'd like the followiung to occur:

single click: do one thing
double click: do an other

Problem is if i double click it executing both the single then double. Since both have tasks that read same file im getting major issues. Why would this be happening anyfixes?

i tried using double click on one and mouse pressed on another same problem......very strange

steve labar
Ranch Hand

Joined: Sep 10, 2008
Posts: 55
oh that mouse click == 5 was ==1 i just was playing around w/ options forgot to change it back!
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2091
    
    7
Problem is if i double click it executing both the single then double. Why would this be happening?


Yes, because thats the way applications are normally designed.

a) a single click selects the item
b) a double click performs some action on the item

And that is why you can also use the keyboard:

a) the arrow keys are used to select an item
b) the Enter key would then typically before an action on the item (although for a JTable the default is to just move to the next row you can always write a custom Action).

Since both have tasks that read same file


Sounds to me like a bad design. Remember what I suggested above. Whatever you can do with the mouse you should be able to do with the keyboard. So it does not make sense to read a file every time you use an arrow key.

But, strangely enough you are not the first person to ask for something like this and I happen to have some old code lying around:


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jtable would like to handle both single click and double click
 
Similar Threads
getting null pointer
Sorting 10 numbers
Movable Objects
How to add MouseLsitener to JMenu
How to use Ploymorphism