Search code examples
javaswingfullscreen

Stopping the use of Tab/Alt-F4 in a full-screen program in Java/Swing


I need a way to stop people using other programs while my Java program is running. i.e stopping people switch tabs and pressing Alt-F4.


Solution

  • To make the program full screen use;

     window.setExtendedState(Frame.MAXIMIZED_BOTH); //maximise window
    
     window.setUndecorated(true); //remove decorations e.g. x in top right
    

    And to make the window always on top use(To stop people using other running programs);

    window.setAlwaysOnTop(true);