![]() |
The Java Developers Almanac 1.4 |
|
e601. Enabling Full-Screen ModeIn full-screen mode, no window can overlap the full-screen window. Also, when in full-screen mode, the display mode typically can be changed if desired (see e605 Setting the Screen Size, Refresh Rate, or Number of Colors). // Determine if full-screen mode is supported directly
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
if (gs.isFullScreenSupported()) {
// Full-screen mode is supported
} else {
// Full-screen mode will be simulated
}
// Create a button that leaves full-screen mode
Button btn = new Button("OK");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
// Return to normal windowed mode
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
gs.setFullScreenWindow(null);
}
});
// Create a window for full-screen mode; add a button to leave full-screen mode
Frame frame = new Frame(gs.getDefaultConfiguration());
Window win = new Window(frame);
win.add(btn, BorderLayout.CENTER);
try {
// Enter full-screen mode
gs.setFullScreenWindow(win);
win.validate();
// ...
} finally {
// Exit full-screen mode
gs.setFullScreenWindow(null);
}
e599. Centering a Frame, Window, or Dialog on the Screen e600. Getting the Number of Screens e602. Double-Buffering in Full-Screen Mode e603. Getting the Available Screen Sizes, Refresh Rates, and Number of Colors e604. Getting the Current Screen Refresh Rate and Number of Colors e605. Setting the Screen Size, Refresh Rate, or Number of Colors
© 2002 Addison-Wesley. |