| Author |
problem add panel to other panel
|
Nouf Nassri
Ranch Hand
Joined: Apr 22, 2010
Posts: 40
|
|
Hello everyone
I have a big problem I have a window that extends Jframe fenetere
contains two panels panel1 contains 2 buttons and panel2 is empty and I have two other panel extends JPanel panel3 panel4 and I like when I click button 1 i want to add 3 to the panel panel2 empty and when I click the button2 I want to add a panel4 panel2 and disappear the panel3 knowing that I work on netbeans:
button 1:
button 2:
but I do not know where is the problem.
Thank you for the help.
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8433
|
|
You need to call revalidate() and repaint() on the parent when you add/remove a child.
If your intention is to display only one panel at one time, but switch panels, the check out CardLayout
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Nouf Nassri
Ranch Hand
Joined: Apr 22, 2010
Posts: 40
|
|
Thank you for your reply I did that
but whenever I click a button I see another side of panel panel2
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8433
|
|
|
revalidate() and repaint() should be called after you add the panel3
|
 |
Nouf Nassri
Ranch Hand
Joined: Apr 22, 2010
Posts: 40
|
|
Maneesh Godbole wrote:revalidate() and repaint() should be called after you add the panel3
Thank you very much got the same problem
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8433
|
|
Post your SSCCE which we can try out in our environment.
With the code you have posted, it is difficult to figure out what is going wrong.
|
 |
 |
|
|
subject: problem add panel to other panel
|
|
|