java全屏代码详解编程语言

import java.awt.*; 
import javax.swing.JFrame; 
 
public class FullScreenTest extends JFrame { 
 
    public static void main(String[] args) { 
 
        DisplayMode displayMode; 
 
        if (args.length == 3) { 
            displayMode = new DisplayMode( 
                Integer.parseInt(args[0]), 
                Integer.parseInt(args[1]), 
                Integer.parseInt(args[2]), 
                DisplayMode.REFRESH_RATE_UNKNOWN); 
        } 
        else { 
            displayMode = new DisplayMode(800, 600, 16, 
                DisplayMode.REFRESH_RATE_UNKNOWN); 
        } 
 
        FullScreenTest test = new FullScreenTest(); 
        test.run(displayMode); 
    } 
 
    private static final long DEMO_TIME = 5000; 
 
 
    public void run(DisplayMode displayMode) { 
        setBackground(Color.blue); 
        setForeground(Color.white); 
        setFont(new Font("Dialog", 0, 24)); 
 
        SimpleScreenManager screen = new SimpleScreenManager(); 
        try { 
            screen.setFullScreen(displayMode, this); 
            try { 
                Thread.sleep(DEMO_TIME); 
            } 
            catch (InterruptedException ex) { } 
        } 
        finally { 
            screen.restoreScreen(); 
        } 
    } 
 
 
    public void paint(Graphics g) { 
        g.drawString("Hello World!", 20, 50); 
    } 
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/10574.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论