I am writing a Java applet, in my applet I simply call setVisible() to control the visibility of some panels.
For example:
pnlAddUser.setVisible(true);
but sometimes showing panel does not work. and when I just click on the border of Applet Viewer window, the panel appears.
I used:
- invalidate()
- setSize(this.getWidth(), this.getHeight())
- this.repaint(this.getGraphics());
- pnlAddUser.r开发者_StackOverflowepaint();
but it doesn't work.
Edit: I should mention, I am using a JTree and when a TreeNode is selected, I show or hide some panels according to the type of the node.
Please help me, Thanks.
Solved. Not good but it works.
I added the code:
public void repaintAgain() {
setSize(this.getWidth() - 1, this.getHeight() - 1);
setSize(this.getWidth() + 1, this.getHeight() + 1);
}
whenever I want to repaint, use this.
精彩评论