anon242463
anon242463

Reputation:

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

Upvotes: 0

Views: 2304

Answers (1)

Marcus Adams
Marcus Adams

Reputation: 53880

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.

Upvotes: 1

Related Questions