• JAVA全屏模式


     1     import java.awt.DisplayMode;  
    2 import java.awt.FlowLayout;
    3 import java.awt.GraphicsDevice;
    4 import java.awt.GraphicsEnvironment;
    5 import java.awt.Insets;
    6 import java.awt.event.ActionEvent;
    7 import java.awt.event.ActionListener;
    8
    9 import javax.swing.JButton;
    10 import javax.swing.JFrame;
    11
    12 public class FullScreenDemo {
    13 public static void main(String[] args) {
    14 JFrame window = new JFrame();
    15
    16 window.setUndecorated(true);
    17 window.setResizable(false);
    18 window.setLayout(new FlowLayout());
    19 JButton button = new JButton("close window");
    20 button.setMargin(new Insets(0, 0, 0, 0));
    21 button.addActionListener(new ActionListener() {
    22 @Override
    23 public void actionPerformed(ActionEvent e) {
    24 System.exit(0);
    25 }
    26 });
    27 window.add(button);
    28
    29 DisplayMode displayMode = new DisplayMode(1440,900,32,75);//分辨率800*600,16色深,75HZ
    30 /*
    31 * 下面为主要的设置全屏
    32 */
    33 GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    34 GraphicsDevice device = environment.getDefaultScreenDevice();
    35 //use the Jframe as the full screen window
    36 device.setFullScreenWindow(window);
    37 //如果要退出全屏
    38 //device.setFullScreenWindow(null);
    39 //change the displaymode
    40 if(displayMode != null && device.isDisplayChangeSupported()){
    41 try {
    42 device.setDisplayMode(displayMode);
    43 } catch (Exception e) {
    44 }
    45 }
    46
    47 }
    48 }

    转自网络!感谢分享!

  • 相关阅读:
    拓扑排序
    Codeforces #503 C. Elections(贪心,逆向
    Codeforces #367 (Div. 2) D. Vasiliy's Multiset (trie 树)
    字典树
    最大子段和
    P1880 [NOI1995] 石子合并
    P1140 相似基因
    P1280 尼克的任务
    [BZOJ4064/Cerc2012]The Dragon and the knights
    [BZOJ4066]简单题
  • 原文地址:https://www.cnblogs.com/Acmen/p/2198245.html
Copyright © 2020-2023  润新知