【发布时间】:2014-05-05 04:49:15
【问题描述】:
我是 JFrame 的新手,正在尝试做一个项目,如果按下注销按钮,以下代码将完美执行,
public void actionlogout() {
lButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
try {
new Login();
setVisible(false);
dispose();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
现在我的问题是,当我尝试从同一个包中的另一个文件调用相同的 actionlogout 时,它要求将方法的类型更改为静态,所以我已将方法更改为静态,但它在 setVisible(false)
Cannot make a static reference to the non-static method setVisible(boolean) from the type Window
我现在要做什么?
【问题讨论】: