aspose file tools
The moose likes Swing / AWT / SWT and the fly likes JFrame question. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "JFrame question." Watch "JFrame question." New topic
Author

JFrame question.

Adam Altmann
Greenhorn

Joined: Jun 08, 2005
Posts: 21
I'm writing an application that has one main JFrame with a menubar. ActionListeners on the menubar call a seperate class, which will generate a JPanel, and that panel then gets added to the main JFrame. As of right now, all selections from the menubar will generate the proper JPanels, and everything works as intended. However, if I generate one type of JPanel, and then select a different one, I get graphical corruption. It looks as though components are being drawn on top of what's already there.

How do I reset the JFrame, making it a "blank slate" before I add a new JPanel?
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Sounds like you're adding new JPanel's on top of the existing ones, or adding the same one twice. JFrame.getContentPane().removeAll() is what you're looking for, though the fact that you're having makes me believe you should probably rethink your design.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: JFrame question.
 
Similar Threads
How to tidy up a swing listener program?
Little advice on JPanels in JFrame
JMenuBar showing gradient background on Mac -- how to disable?
about JFrame , JPanel and JMenuBar
Implementing listeners to menu events