How can I create a Java Swing app that covers the Windows Title bar?

前端 未结 3 559
野的像风
野的像风 2021-01-06 02:35

I\'m working on a java swing application that will be used in a psychology experiment and the researchers have requested that I make the program \"black out the screen\" in

3条回答
  •  旧时难觅i
    2021-01-06 02:41

    Use the Full Screen Java APIs?

    http://java.sun.com/docs/books/tutorial/extra/fullscreen/exclusivemode.html

    http://www.artificis.hu/2006/03/16/java-awtswing-fullscreen

    JFrame fr = new JFrame();
    fr.setResizable(false);
    if (!fr.isDisplayable()) {
        // Can only do this when the frame is not visible
        fr.setUndecorated(true);
    }
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    try {
      if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(fr);
      } else {
        // Can't run fullscreen, need to bodge around it (setSize to screen size, etc)
      }
      fr.setVisible(true);
      // Your business logic here
    } finally {
      gd.setFullScreenWindow(null);
    }
    

提交回复
热议问题