开发者

setVisible in Java Applet not working

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜