Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Swing design

Tags:

java

swing

I have a question regarding coding a Swing UI. If I want to make a software with some option e.g. on the first Frame I have three buttons (New, Option, Exit).

Now if a user clicks the new button, I want to change the entire content in the Frame to something else. I know I have to use addActionListener to that button. But my question is how to change the contents in the frame. Creating new Frames and then use setVisible() isn't an option for me.

And to use frame.remove() all the objects seems awkward if it is several things that needs to be removed. Or is it the right way?

like image 333
starcorn Avatar asked Aug 10 '26 06:08

starcorn


1 Answers

Look into the Card Layout. I would also probably use menu items instead of buttons.

like image 133
camickr Avatar answered Aug 11 '26 19:08

camickr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!