Fullscreen demo and JFram without title

This commit is contained in:
iryupnik 2020-03-31 13:36:54 +02:00
parent 5e92ce66d0
commit ebc662ffa0

View File

@ -28,6 +28,7 @@ public class WindowOfFreeMove extends JFrame {
public static final int KEY_RIGHT = 39;
public static final int KEY_DOWN = 40;
public static final int KEY_EVENT = 69;
public static final int KEY_FULLSCREEN = 115;
private Canvas canvas;
private DialogBar dialogBar;
@ -109,6 +110,14 @@ public class WindowOfFreeMove extends JFrame {
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KEY_FULLSCREEN){
if (getExtendedState() == MAXIMIZED_BOTH)
setExtendedState(NORMAL);
else
setExtendedState(MAXIMIZED_BOTH);
return;
}
if (canPersonMove) {
nextMove = e.getKeyCode();
inputTimer.start();
@ -130,10 +139,9 @@ public class WindowOfFreeMove extends JFrame {
lp.add(canvas, JLayeredPane.PALETTE_LAYER);
lp.add(dialogBar, JLayeredPane.POPUP_LAYER);
setTitle("Ahoj");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setBounds(0, 0, CELL_SIZE * WINDOW_WIDTH, CELL_SIZE * WINDOW_HEIGHT + CELL_SIZE / 2);
setUndecorated(true);
setBounds(0, 0, CELL_SIZE * WINDOW_WIDTH, CELL_SIZE * WINDOW_HEIGHT);
setLocationRelativeTo(null);
setResizable(false);
setVisible(true);