looks
  1. looks
  2. LOOKS-186

Allowing Look and Feel initialization in headless mode

    Details

    • Type: Task Task
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.2.1
    • Fix Version/s: not determined
    • Component/s: common
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      186

      Description

      We have the following use case for headless: our product can generate images in
      a distributed environment and that generation will occur on machines with no
      display.

      We set the Plastic look and feel on startup, but when there is no display, a
      HeadlessException is thrown by LookUtils:

      java.awt.HeadlessException
      at sun.awt.HeadlessToolkit.getScreenResolution(Unknown Source)
      at com.jgoodies.looks.LookUtils.isLowResolution(LookUtils.java:479)
      at com.jgoodies.looks.LookUtils.<clinit>(LookUtils.java:248)

      This is an important use case for us. We would appreciate your consideration of
      a graceful fallback when no display exists.

        Activity

        Hide
        jaredmac added a comment -

        Confirmed that this still is true in version 2.2.1

        Show
        jaredmac added a comment - Confirmed that this still is true in version 2.2.1
        Hide
        karsten added a comment -

        I suggest that you check for headless mode, before you set any Look&Feel, see
        GraphicsEnvironment#isHeadless().

        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        if (!ge.isHeadless())

        { set the L&f create components access toolkit, etc }

        A L&F implementation may want to configure itself by accessing the (then absent)
        GraphicsEnvironment or Toolkit. Several parts in the Plastic are or may be
        affected. It's not just the screen resolution. For example the drop shadow
        popups are affected too.

        In Sun Java 6, setting the Sun Windows-L&f even ends with a VM failure.

        So, I'd say it's better to not set the L&F. That's even better than catching the
        HeadlessException, which is also what you could do.

        Show
        karsten added a comment - I suggest that you check for headless mode, before you set any Look&Feel, see GraphicsEnvironment#isHeadless(). GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); if (!ge.isHeadless()) { set the L&f create components access toolkit, etc } A L&F implementation may want to configure itself by accessing the (then absent) GraphicsEnvironment or Toolkit. Several parts in the Plastic are or may be affected. It's not just the screen resolution. For example the drop shadow popups are affected too. In Sun Java 6, setting the Sun Windows-L&f even ends with a VM failure. So, I'd say it's better to not set the L&F. That's even better than catching the HeadlessException, which is also what you could do.
        Hide
        jaredmac added a comment -

        Sorry, I realized I wasn't clear: the important issue is that we want to do
        off-screen rendering of components identical to an on-screen rendering, so we
        need to set the look-and-feel. If we don't, a user's off-screen image would
        differ from the on-screen one.

        Sun's Windows and Ocean L&Fs both support rendering in headless mode. We would
        really like to see this support in the JGoodies L&F, as this off-screen
        rendering is an important use case for us.

        Thanks,
        Jared

        Show
        jaredmac added a comment - Sorry, I realized I wasn't clear: the important issue is that we want to do off-screen rendering of components identical to an on-screen rendering, so we need to set the look-and-feel. If we don't, a user's off-screen image would differ from the on-screen one. Sun's Windows and Ocean L&Fs both support rendering in headless mode. We would really like to see this support in the JGoodies L&F, as this off-screen rendering is an important use case for us. Thanks, Jared

          People

          • Assignee:
            looks-issues
            Reporter:
            jaredmac
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: