• Post Reply Bookmark Topic Watch Topic
  • New Topic

A frame, 3 Panels and a button.

 
john von
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im new to GUI and having problem on repainting a panel.

I have 4 classes. Namely, MainFrame(JFrame subclass), NorthPanel(JPanel), CenterPanel(JPanel) and SouthPanel(JPanel).

MainFrame holds the 3 panels(classes) in a BorderLayout.
Now, SouthPanel has a button and an action listener that suppose to repaint the CenterPanel. So how would i call it or repaint repaint the CenterPanel inside the MainFrame? And where should i call the repaint?

I know this is really simple to you guys. Thanks in advance!

Thanks!
[ July 20, 2004: Message edited by: john von ]
 
Serghei Jelauc
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
As I understood you created instances of the panels in class that extends JFrame. You can create in you SouthPanel class constructor that will receive an object of MainFrame type, and in you ActionListener for the button you can call the repaint() method of MainFrame type object.
Something like this.



Hope it will help
[ July 21, 2004: Message edited by: Serghei Jelauc ]
 
john von
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There actually 2 panels and a frame involved(3 classes). There is CenterPanel that should be repainted. But the button that will trigger repaint is in SouthPanel. You almost had it.

So how? Thanks again!
 
john von
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any help?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!