これが私のメインクラスです
package Apocalypse;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Main extends JFrame{
private int xSize, ySize;
public Main(){
super("Zombie Apocalypse");
Toolkit tk = Toolkit.getDefaultToolkit();
xSize = (int) tk.getScreenSize().getWidth();
ySize = (int) tk.getScreenSize().getHeight();
setSize(xSize,ySize);
setUndecorated(true);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
kfm.addKeyEventDispatcher(new MyDispatcher());
add(new Level1());
setVisible(true);
}
public static void main(String[] args){
new Main();
}
private class MyDispatcher implements KeyEventDispatcher{
public boolean dispatchKeyEvent(KeyEvent e){
if(e.getID() == KeyEvent.KEY_PRESSED){
if(e.getKeyCode() == KeyEvent.VK_ESCAPE){
System.out.println("It Worked");
setUndecorated(false);
}
}
return false;
}
}
}
KeyEventDispatcher クラスでわかるように、ゲームを閉じることができるように Undecorated を false に設定したいのですが、機能しません。どうすればいいですか?