Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

revalidate() vs. repaint()

843804Jan 1 2005 — edited Jan 3 2005
I have a JPanel in a JTabbedPane. I have an ActionListener attached to a JMenuItem that does basically this:
	getNorthEastPanel().removeAll();
	getNorthEastPanel().add(newPanelContents);
	getNorthEastPanel().repaint();
That works just fine.

I also have a MouseListener elsewhere that updates this panel, using a reference to the GUI passed into the containing class. From the MouseListener, the contents are removed, but the JPanel doesn't repaint until either I minimize/maximize, or click on it. If I call revalidate(), it does repaint the JPanel - the desired behavior.

So, I have a workaround. But my question is, what's going on here? (I don't have a test case... if someone thinks it might help, I'll work one up.) Why would the same code work in one place and not in another place?

tia
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 31 2005
Added on Jan 1 2005
5 comments
2,693 views