Class GraphicsEnvironment
GraphicsEnvironment — the browser
viewport presented as a local display, so the maximize-to-screen idiom ports
unchanged:
GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
frame.setMaximizedBounds(e.getMaximumWindowBounds()); // (0, 0, viewport)
frame.setExtendedState(frame.getExtendedState() | Frame.MAXIMIZED_BOTH);
isHeadless() is false. The JDK's answer on a server is
true, which silently sends a migrated app down its no-display branch —
skipping the UI it was about to build. A browser is a display, so this reports
one, and every screen query below answers rather than throwing
HeadlessException.
Like Toolkit this does not extend the abstract JDK class — it is the
import-swap surface, not a platform environment — and selects per-method
behaviour by the same tiers:
- Browser-backed, via the default device's configuration:
getMaximumWindowBounds(),getCenterPoint(),getScreenDevices(),getDefaultScreenDevice(). - Delegated to the headless JDK environment, which computes these
correctly and is authoritative for them because they describe the
server's fonts — the same fonts
Toolkit.getFontMetrics(Font)measures with:createGraphics(BufferedImage),getAllFonts(),getAvailableFontFamilyNames(),registerFont(Font),preferLocaleFonts(),preferProportionalFonts().
No method WARNs: every one of them has a real answer here.
Font delegation is what keeps getAvailableFontFamilyNames()
consistent with what a FontMetrics measurement will actually
report, which is the only sense in which font queries can be right at
all when the glyphs are ultimately rendered by the browser.
-
Method Summary
Modifier and TypeMethodDescriptionFont[]String[]String[]static GraphicsEnvironmentThe area a maximized window should fill: the viewport, less any screen insets.static booleanbooleanvoidvoidbooleanregisterFont(Font font)
-
Method Details
-
getLocalGraphicsEnvironment
-
isHeadless
public static boolean isHeadless()- Returns:
- always false; see the class doc for why the JDK's
trueis the wrong answer
-
isHeadlessInstance
public boolean isHeadlessInstance()- Returns:
- always false — see
isHeadless()
-
getScreenDevices
-
getDefaultScreenDevice
-
getMaximumWindowBounds
The area a maximized window should fill: the viewport, less any screen insets. -
getCenterPoint
-
createGraphics
-
getAllFonts
-
getAvailableFontFamilyNames
-
getAvailableFontFamilyNames
-
registerFont
- Returns:
- false if
fontconflicts with a family already present — the JDK's own contract, delegated rather than reimplemented - Throws:
NullPointerException- iffontis null
-
preferLocaleFonts
public void preferLocaleFonts() -
preferProportionalFonts
public void preferProportionalFonts()
-