我有这个程序与设置少量的,它应该是这样的:
http://img4.imageshack.us/img4/8527/programbillede.png(对不起,倾斜后的图像。)
,这是加载在主然后隐藏,然后当我通过其他功能运行,然后尝试再次显示,则它看起来像这样:
http://img696.imageshack.us/img696/6886/programbillede1.png(对不起,无法发布图像..)
几个按钮是可见的是因为当你把鼠标放在这个上面时,你可以看到它们,但你永远不会看到3个标签......帮助.. :)组件设置visable为false,然后到真正消失后再次
然后问任何问题.. :)
这就是我所说的设置的东西.. doMain只是隐藏主菜单部分。
}else if(e.getActionCommand().equals("Indstillinger")){
doMain(false);
Exit.setVisible(true);
Exit.setBounds(650, 135, 70, 20);
returntomain.setVisible(true);
settings.setvisable(true);
OPS ..忘了settings.setvisable看起来像这样..
public void setvisable(boolean doWhat){
panel1.setVisible(doWhat);
panel2.setVisible(doWhat);
panel3.setVisible(doWhat);
}
,这是从我的设置访问任何东西的唯一的事情..
private Image tilfojbillede(int nr) throws IOException{
String navn=("/Resources/"+Indstillinger.BilledeMappe+"/"+(nr+1)+".png");
return ImageIO.read(getClass().getResource(navn));
}
和设置由3个面板组成,如下图所示:
panel1.setBounds(50, 150, 150, 200);
panel1.setVisible(false);
panel2.setBounds(200, 150, 150, 100);
panel2.setVisible(false);
panel3.setBounds(350, 150, 150, 200);
panel3.setVisible(false);
和我把这些2班在我的主,因为像这样的全局函数...
public static Indstillinger settings= new Indstillinger();
public static Spillet spillet= new Spillet();
我希望你们能帮助我从这个信息..
请发布[SSCCE](http://sscce.org/)。否则,我们无法帮助你。 – Howard 2011-04-24 08:35:54
让我们看看一些有问题的代码。尽量使其尽可能小,以便1)编译和2)说明问题。 – corsiKa 2011-04-24 08:36:02
(只是猜测)尝试在容器的可见性正在改变的组件的容器上调用'revalidate'。您需要在更改布局时调用'revalidate',并且我认为不可见元素的大小为零,所以这将是布局更改。 – sjr 2011-04-24 08:45:11