Code-Apprentice
Code-Apprentice

Reputation: 83527

Using CardLayout in NetBeans GUI Builder

I am using the NetBeans 7.2.1 GUI Builder. I could do all of this by hand. Instead, I am using my current project to learn how this tool works so that I can make an informed decision of when to use it in the futre (if at all).

Now with help of archived questions here, I have figured out how to change the LayoutManager to a CardLayout. I have also added three JPanels to the layout (although, there seems to be a bug...maybe a question about that later). The first JPanel displayed by the CardLayout will have two buttons. Each button will cause the CardLayout to display one of the other two JPanels. To do this, I found that I can use CardLayout#show(Container, String).

I need to know what the value of the String is for each JPanel. Doing some further research, I found that NetBeans generates a line of code such as

getContentPane().add(addCardsPanel, "card2");

So I can use "card2" to show addCardsPanel. It would be convenient to use a more applicable String. Will NetBeans allow me to set this identifying String to whatever value I wish? If so, how do I do it?

Upvotes: 0

Views: 1370

Answers (1)

MadProgrammer
MadProgrammer

Reputation: 347194

In the Navigator window select the panel you want.

In the Properties window scroll down to the Layout group. You'll see a Card Name property. Knock your self out ;)

Upvotes: 2

Related Questions