简体   繁体   中英

adding jpanel into a jframe. netbeans

i am particularly using netbeans gui editor and i am new to gui

i have a jframe created and I added jtabbedpanel.

inside the jtabbedpanel i have 2 panels that i call standard and compact

i have set standardPanel = new ImagePanel(); which ImagePanel.java is located on different java file

how am I suppose to put a panel on different file for reusability ?

i obviously dont want all the codes in a single file.

is this the right way to design a gui ?

thanks

You should create your own class, something like "CustomPanel" that extends from JPanel. You put that class in its own file, and everything that goes on the JPanel should be a part of that class.

Then, instead of adding a JPanel to the tabbed panel, you create an instance of CustomPanel and add it to the tabbed panel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM