Friday, May 21, 2010

How do you make a button that opens an existing frame in java?

I want to make a menu screen with buttons that link to existing frames.

How do you make a button that opens an existing frame in java?
Add an event handler to each button, then, in the field for the action, use the frame.show() method. If you don't want your menu frame to show while the other one's up, use frame.hide(). And then, when whatever button used for closing the new frame is pressed, make sure you show the menu frame again.





button.addActionListener( new ActionListener() { void actionPerformed (ActionEvent e) { frame.show(); } } );





...or something of that nature.


No comments:

Post a Comment