开发者

Components disappearing after setting visable to false and then to true again

开发者 https://www.devze.com 2023-02-28 14:53 出处:网络
i have this program with a small amount of settings, and it should look like this: http://img4.imageshack.us/img4/8527/programbillede.png (sorry, cant post images..)

i have this program with a small amount of settings, and it should look like this:

http://img4.imageshack.us/img4/8527/programbillede.png (sorry, cant post images..)

and this is loaded in main and then hidden, and then when i run through some other functions, and try to show this again, then it looks like this:

http://img696.imageshack.us/img696/6886/programbillede1.png (sorry, cant post images..)

the few buttons that are visible are because when you mouse over this then you can see them, but you can never get to see the 3 labels... help .. :)

any questions then ask .. :)

this is how i call the settings thing .. doMain just hides the main menu parts.

}else if(e.getActionCommand().equals("Indstillinger")){
        doMain(false);
        Exit.setVisible(true);
        Exit.setBounds(650, 135, 70, 20);
        returntomain.setVisible(true);
        settings.setvisable(true);

ops .. forgot the settings.setvisable looks like this..

public void setvisable(boolean doWhat){
    panel1.setVisible(doWhat);
    panel2.setVisible(doWhat);
    panel3.setVisible(doWhat);
}

and this is the only thing which accesses anything from my settings..

private Image tilfojbillede(int nr) throws IOException{
    String navn=("/Resources/"+Indstillinger.BilledeMappe+"/"+(nr+1)+".png");
    return ImageIO.read(getClass().getResource(navn));
}

and the settings consists of 3 panels made like this in a constructor...

    panel1.setBounds(50, 150, 150, 200);
    panel1.setVisible(false);
    panel2.setBounds(200, 150, 150, 100);
 开发者_JAVA技巧   panel2.setVisible(false);
    panel3.setBounds(350, 150, 150, 200);
    panel3.setVisible(false);

and i call these 2 classes in my main, as a global function like this...

    public static Indstillinger settings= new Indstillinger();
    public static Spillet spillet= new Spillet();

i hope you guys can help me from this information ..


You need to call revalidate(); and maybe repaint(); as well.

0

精彩评论

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