如何為 Java Swing 應用程式設定全屏模式?
若要為 Java Swing 應用程式設定全屏模式,請使用 setFullScreenWindow() 方法
GraphicsDevice device = graphics.getDefaultScreenDevice();
JFrame frame = new JFrame("Fullscreen");
device.setFullScreenWindow(frame);以下是一個為 Java Swing 應用程式設定全屏模式的示例
示例
import java.awt.Color;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class SwingDemo {
public static void main(String[] args) {
GraphicsEnvironment graphics =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = graphics.getDefaultScreenDevice();
JFrame frame = new JFrame("Fullscreen");
JPanel panel = new JPanel();
JLabel label = new JLabel("", JLabel.CENTER);
label.setText("This is in fullscreen mode!");
label.setOpaque(true);
frame.add(panel);
frame.add(label);
frame.setUndecorated(true);
frame.setResizable(false);
device.setFullScreenWindow(frame);
}
}輸出如下,在全屏顯示應用程式
輸出

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP