我正在开始一个Java项目,需要一种方法来完全锁定一个框架。锁定我的意思是:
基本上,这是全屏收购。
答案 0 :(得分:3)
尝试使用fullscreen exclusive mode并查看它是否适合您。
答案 1 :(得分:1)
您可以尝试以下内容:
import javax.swing.*;
import java.awt.*;
public class FullScreenTest extends JFrame {
private GraphicsDevice device;
private boolean isFullScreen = false;
public FullScreenTest(GraphicsDevice device) {
super(device.getDefaultConfiguration());
this.device = device;
setTitle("Display Mode Test");
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
private void initComponents(Container c) {
setContentPane(c);
c.setBackground(Color.RED);
}
public void begin() {
isFullScreen = device.isFullScreenSupported();
setUndecorated(isFullScreen);
setResizable(!isFullScreen);
if (isFullScreen) {
// Full-screen mode
device.setFullScreenWindow(this);
validate();
} else {
// Windowed mode
pack();
setVisible(true);
}
}
public static void main(String[] args) {
GraphicsEnvironment env = GraphicsEnvironment.
getLocalGraphicsEnvironment();
GraphicsDevice[] devices = env.getScreenDevices();
FullScreenTest test = new FullScreenTest(devices[0]);
test.initComponents(test.getContentPane());
test.begin();
}
}