1

I have a java method activated by a mouse click on a button

 private void backButtonMouseClicked(java.awt.event.MouseEvent evt) { do stuff }

is there some way to virtually use this method from another method without clicking the mouse on the button?

3 Answers 3

1

Or you can just use button.doClick();

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

2 Comments

I can see the button being clicked programatically but the function it is supposed to perform does not happen. When I click it with the mouse it does function? what am I missing?
Don't know. You must not have the proper reference to the button.
0

Yes, MouseEvent has public constructors, so you simply create one, and call the function with it.

Comments

0

I believe you can say backButtonMouseClicked(new MouseEvent()) to call the method. Or maybe backButtonMouseClicked(null).

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.