Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating JPanel obscuring JMenu

 
J S
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Obscured,
Joe
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using the repaint() method instead of update(getGraphics())... that's "The Way You're Supposed To Repaint"™
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic