一个简单的GUI的问题
java中组件设置不可视后是不是就永远不能可视了,例如以下程序:
import java.awt.*;
import java.awt.event.*;
public class TestVisible
{
public static void main(String[]args)
{
Frame f = new Frame();
final Button b1 = new Button();
Button b2 = new Button();
b1.setVisible(false);
b2.setVisible(true);
b2.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
b1.setVisible(true);
}
});
f.add(b1, "North ");
f.add(b2, "South ");
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
f.setSize(300,300);
f.setVisible(true);
}
}
怎么解决这种问题啊
------解决方案--------------------调用volidate()方法来刷新界面显示...看看API就好了..
------解决方案--------------------validate