By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,505 Members | 1,034 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,505 IT Pros & Developers. It's quick & easy.

Java/Swing: How to Create a New JPanel & Place it Right on Top of Another JPanel.

P: 37

I have a question regarding Java and Swing programming I wonder if I could ask the forum for some help.

I have a JPanel that has a couple of radio buttons and an "OK/Next" button on it. When a radio button wass selected and "OK/Next" was clicked on, I was able to write some code inside the "ActionPerformed" method to verify that the radio button was selected as intended. But that was only a quick test to see that things worked. What I would really like to do is, when "OK/Next" clicked, to create a new JPanel and place this new JPanel right on top of the first JPanel (then I would use the new JPanel to collect some info from the user).

The question I have is :
- Is inside the "ActionPerformed" method the right place to create a new
- And how do I create a new JPanel and place it on top of the first JPanel (I
used NetBeans to create the first JPanel and did not write the code for it)?

Any information, instructions, and code example are much appreciated.

Thank you,

Jul 23 '08 #1
Share this Question
Share on Google+
1 Reply

P: 13,264
You now need to write the codes yourself. As you can see Netbeans doesn't do allthe majic for you.
A JPanel is also a container and so you can add other components (including JPanels) to it.
Jul 24 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.