Class GraphicsEnvironment

java.lang.Object
vaadinx.awt.GraphicsEnvironment

public final class GraphicsEnvironment extends Object
Import-swap target for 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:

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 Details

    • getLocalGraphicsEnvironment

      public static GraphicsEnvironment getLocalGraphicsEnvironment()
    • isHeadless

      public static boolean isHeadless()
      Returns:
      always false; see the class doc for why the JDK's true is the wrong answer
    • isHeadlessInstance

      public boolean isHeadlessInstance()
      Returns:
      always false — see isHeadless()
    • getScreenDevices

      public GraphicsDevice[] getScreenDevices()
    • getDefaultScreenDevice

      public GraphicsDevice getDefaultScreenDevice()
    • getMaximumWindowBounds

      public Rectangle getMaximumWindowBounds()
      The area a maximized window should fill: the viewport, less any screen insets.
    • getCenterPoint

      public Point getCenterPoint()
    • createGraphics

      public Graphics2D createGraphics(BufferedImage img)
    • getAllFonts

      public Font[] getAllFonts()
    • getAvailableFontFamilyNames

      public String[] getAvailableFontFamilyNames()
    • getAvailableFontFamilyNames

      public String[] getAvailableFontFamilyNames(Locale l)
    • registerFont

      public boolean registerFont(Font font)
      Returns:
      false if font conflicts with a family already present — the JDK's own contract, delegated rather than reimplemented
      Throws:
      NullPointerException - if font is null
    • preferLocaleFonts

      public void preferLocaleFonts()
    • preferProportionalFonts

      public void preferProportionalFonts()