Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jtable would like to handle both single click and double click

 
steve labar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh that mouse click == 5 was ==1 i just was playing around w/ options forgot to change it back!
 
Rob Camick
Ranch Hand
Posts: 2584
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic