• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanel refreshing  RSS feed

 
Amadeus Ward
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I hope you'll be able to help me out with this problem. I have a big panel in the main frame. The panel contains logopanel, qpanel and buttonpanel. After a question is displayed in the qpanel I create a new qpanel: qpanel = qTable[1].loudPanel() ; and want to show it. So I'm refreshing it, revalidating but nothing works. I suspect that it might be wrong because I don't delete the qpanel from the panel, I only change the reference.
I have no idea what to do.
any help highly appreciated.
thank you



 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the "Code" tags when posting code.

You are correct you can't just change the reference to a variable and expect the component to appear in the frame. You need to add the component to the panel of the frame.

Maybe a better option is to use a Card Layout.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

I suspect that it might be wrong because I don't delete the qpanel from the panel, I only change the reference.

Thats correct. In pseudo code, you need to do something like this:

 
Amadeus Ward
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds good. However, i got BoxLayout in the panel. So, if I remove the old qpanel and add a new one, it's gonna end up at the bottom right? That's what I'm concerned about:/

Also, CardLayout is really nice and neat, but I want to have more than 2 questions. So I guess I'll have to change a reference anyway and I'm not sure if that will work. But let me try.

And thank you for all your suggestions so far. I really appreciate your help.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amadeus Ccc wrote:Sounds good. However, i got BoxLayout in the panel. So, if I remove the old qpanel and add a new one, it's gonna end up at the bottom right? That's what I'm concerned about:/

Check out Container#add(Component component,int index)
 
Amadeus Ward
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works perfect with a lot of questions. Aaaaawwweeeesome

Thank you so much once again!
Thank you for the fast responses
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!