here's my code:
if (KeyEvent.VK_F1 == e.getKeyCode()){
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
frame.setUndecorated(false);
frame.setVisible(true);
}
if(KeyEvent.VK_F2 == e.getKeyCode()){{
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
frame.setUndecorated(true);
frame.setVisible(true);
}