全屏幕显示

    技术2022-05-11  95

    import java.awt.*; import java.awt.event.*; import javax.swing.*; public class FullScreenTest {     public static void main (String[] args)     {                 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment ();         GraphicsDevice gd = ge.getDefaultScreenDevice ();         TestFullScreen myWindow = new TestFullScreen ();                 if ( gd.isFullScreenSupported () )//如果支持全屏             gd.setFullScreenWindow (myWindow);         else             System.out.println ("Unsupported full screen.");             } } class TestFullScreen extends JWindow {     public TestFullScreen ()     {         this.addMouseListener (new MouseAdapter ()         {             public void mousePressed (MouseEvent evt)             {                 //  TestFullScreen.this.setPreferredSize(new Dimension(200,300));                 quit ();                 //System.exit(0);             }         });     }         public void quit ()     {         this.dispose ();     }         public void paint (Graphics g)     {         g.setFont (new Font ("system",Font.BOLD,30));         g.setColor (Color.RED);         g.drawString ("这是全屏幕模式",100,100);             }     }  

    最新回复(0)