我正在尝试为游戏创建标题屏幕。到目前为止一切都很好,除了这个 JFrame 拒绝关闭。我在不同 JFrame 中的不同 JPanel 中使用 JButton。我得到错误
“无法从类型 Window 对非静态方法 setVisible(boolean) 进行静态引用”
package ZombieFunTimeGo;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SuperZombieFunTimeGo extends JFrame{
private TitleScreen ts;
boolean visible;
public SuperZombieFunTimeGo() {
add(new TitleScreen());
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(1280, 720);
ts = new TitleScreen();
Container pane = getContentPane();
pane.add(ts);
setContentPane(ts);
setLocationRelativeTo(null);
setTitle("Super Zombie Fun Time Go!");
setResizable(false);
setVisible(true);
}
public void pullThePlug() {
WindowEvent wev = new WindowEvent(this, WindowEvent.WINDOW_CLOSING);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev);
}
public static void main(String[] args) {
new SuperZombieFunTimeGo();
}
}