Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

A frame, 3 Panels and a button.

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any help?
 
You're not going crazy. You're going sane in a crazy word. Find comfort in this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic