Java Swing JFrame实现全屏--无标题,无边框
实现方式一:
import java.awt.Dimension;import java.awt.Toolkit;
import javax.swing.JFrame;
public class TestJFrame extends JFrame {
public static void main(String[] args) {
TestJFrame frame = new TestJFrame();
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension dimension = kit.getScreenSize();
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setBounds(0, 0, dimension.width, dimension.height);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setUndecorated(true);
frame.setVisible(true);
}
}
使用setUndecorated()方式实现
禁用或启用此窗体的装饰。只有在窗体不可显示时才调用此方法。就是要在setVisible之前调用
实现方式二:
import java.awt.GraphicsDevice;import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;
public class TestJFrame extends JFrame {
public static void main(String[] args) {
TestJFrame frame = new TestJFrame();
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice();
gd.setFullScreenWindow(frame);
}
}
以上是 Java Swing JFrame实现全屏--无标题,无边框 的全部内容, 来源链接: utcz.com/z/390229.html