File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Updating JPanel obscuring JMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Updating JPanel obscuring JMenu" Watch "Updating JPanel obscuring JMenu" New topic

Updating JPanel obscuring JMenu


Joined: May 29, 2003
Posts: 1
Oh, this one might drive me into the ground -- please help!
I have a JPanel that is being drawn on and updated by a swing timer. The swing timer generates an ActionEvent every 30ms and the JPanel has an ActionEventListener that handles the event by calling update(getGraphics()). In the JPanel's paintComponent method, I am drawing an object (which is actually a seperate thread) that is moving, thus the animation. The problem is that the damn JPanel is constantly over the top of my menu.
I've seen numerous issues that seem similar to mine regarding light/heavyweight component problems -- but these are both supposed to be lightweight components! How do I make the menu always on top of a JPanel that is handling a swing timer for animation?
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

Try using the repaint() method instead of update(getGraphics())... that's "The Way You're Supposed To Repaint"™

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: Updating JPanel obscuring JMenu
It's not a secret anymore!