2

how to make single click action to work as double click, in windows we have functionality like when we click on folder it will open on single click.in java is there is any way to do it?

on one click it should select the folder and open the folder.

3
  • hmm ... not entirely sure what you want: if you mean to get the same behaviour as configured in the OS automatically you'r probably out off luck (would love to be proven wrong, though :) Commented Mar 14, 2012 at 12:30
  • Could you add a little bit more detail? In what context do you want that to happen? If you want all single-click events to be transformed into double-clicks, you could simply write your own EventQueue and do it, but I think that it would cause more trouble than anything. Commented Mar 14, 2012 at 12:36
  • double click functionality should be implemented to single click.Like selecting the Cell should get focus and popup should display simultaneously. Commented Mar 14, 2012 at 13:31

1 Answer 1

3

You should generate a double-click event from the "single-click" handler.

Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
     new MouseEvent( Component,MouseEvent.MOUSE_CLICKED,_,_,_,_,2,_) );

See MouseEvent for the meaning of all the parameters - the underscores are things you have to fill and the two is the number of clicks. Remember that you can use most of information received in the event object in the single-click handler and just change the number of clicks.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.