JAVA GUI 开发---全屏

下面是实现全屏的代码,简单明了。

import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class FullScreenTest {
 private JFrame jframe;
 private JLabel jlabel;
 
 public FullScreenTest(){
  jframe = new JFrame();
  jlabel = new JLabel();
  init();
 }
 
 private void init(){
  jframe.setTitle("全屏幕测试");
  jlabel.setText("现在是全屏模式");
  jframe.setUndecorated(true);
  jframe.getGraphicsConfiguration().getDevice().setFullScreenWindow(jframe);
  jframe.setLayout(new FlowLayout());
  jframe.add(jlabel);
  
 }
 
 public void showMe(){
  jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  jframe.setVisible(true);
 }
 
 public static void main(String[] args) {
  new FullScreenTest().showMe();
 }

}

你可能感兴趣的:(java,GUI,全屏)