Skip to content

Look and feel defaults to Nimbus on Windows #45

Closed

Description

@tresf

With the latest Beta, Windows defaults to Nimbus Look and Feel (CrossPlatformLookAndFeel) whereas I would like to specifically set it to the Windows theme (SystemLookAndFeel)or something else of my choosing.

image

Activity

  1. dorkbox commented on Feb 7, 2017

    @dorkbox
    Owner

    Very strange -- I don't think I'm doing anything with the look and feel... I'll see what might be going on, but maybe it's from some testing code from @Vzor-?? I do know we were testing an issue with setting the L&F at one point.

  2. tresf commented on Feb 7, 2017

    @tresf
    Author

    maybe it's from some testing code from @Vzor-

    I'm using RC9 from your downloads area and @Vzor- has zero commits on your master branch, so none I'm aware of.

  3. tresf commented on Feb 7, 2017

    @tresf
    Author

    Is there a chance you're accidentally initializing a Swing component before init() is called (such as in a static method?)

  4. Vzor- commented on Feb 8, 2017

    @Vzor-

    Ill whip up a test case tonight to verify it is not in our code.

  5. Vzor- commented on Feb 8, 2017

    @Vzor-

    I pushed the test, this issue seems to be in dorkbox. Vzor-@37712f5 I'll help more after some sleep 😴

  6. Vzor- commented on Feb 8, 2017

    @Vzor-

    The issue occurs here https://github.com/Vzor-/SystemTray/blob/master/src/dorkbox/systemTray/SystemTray.java#L789

    It resolves as a dorkbox.systemTray.swingUI._SwingTray but that is about the extent of what I can see with the debugger.

  7. Vzor- commented on Feb 8, 2017

    @Vzor-

    Dug a bit deeper, the issue is with the systemutil. The tray initializes and waits on a setEnabled in MenuItem. It then sits on this invokeLater in _SystemTray, at this point it is still a windows look and feel, but as soon as it enters the systemUtil, it runs some custom L&F logic and sets the look and feel to CUSTOM_LOOK_AND_FEEL, which is nimbus, even if I try to set it in test tray.

  8. Vzor- commented on Feb 8, 2017

    @Vzor-

    The menu looks strange under any l&f that isn't Nimbus
    capture
    may be a tough one to fix

  9. dorkbox commented on Feb 8, 2017

    @dorkbox
    Owner

    I fixed the issue with the SystemUtil, so it's not set to a default value - I'll see what can be done about making the menu look nice

  10. tresf commented on Feb 8, 2017

    @tresf
    Author

    @dorkbox can you reference the commit so we can learn from the change and also close the bug report?

  11. dorkbox commented on Feb 8, 2017

    @dorkbox
    Owner

    Not exactly. It's an internal library change (from "Nimbus" -> null) that isn't on github yet. I'm in the process of adding it to github, but its taking a while. As soon as it's added, I'll reference the commit so you can see it.

  12. dorkbox commented on Feb 10, 2017

    @dorkbox
    Owner

    @tresf the commit that fixed this is : dorkbox/Utilities@d8f0c4d I am still trying to figure out how to make the tray look nice WITHOUT the nimbus L&F (and also, with it...). Once that is resolved, I'll close this issue.

  13. tresf commented on Feb 10, 2017

    @tresf
    Author

    I am still trying to figure out how to make the tray look nice WITHOUT the nimbus L&F (and also, with it...). Once that is resolved, I'll close this issue.

    I don't understand this statement. Swing looks fine and it should be on the developer to change L&F. What's wrong with Swing?

  14. dorkbox commented on Feb 10, 2017

    @dorkbox
    Owner

    I'm customizing the menu and menu items slightly (just the margins) which looked nice on Nimbus (even though I didn't realize it was Nimbus), and it looked wonky without it. IE: https://github.com/dorkbox/SystemTray/blob/master/src/dorkbox/systemTray/swingUI/AdjustedJMenuItem.java

  15. tresf commented on Feb 10, 2017

    @tresf
    Author

    Which looked nice on Nimbus (even though I didn't realize it was Nimbus),

    Couldn't this be the problem? Swing defaults should be very close to the OS (if not, it's an Oracle bug that we should report or workaround), I would discourage changing anything that's not necessary.

  16. 80 remaining items

  17. dorkbox commented on Jul 6, 2017

    @dorkbox
    Owner

    It is possible to get it close, but it's not exact, and the HiDPI stuff really buggers up the spacing/size.

  18. tresf commented on Jul 6, 2017

    @tresf
    Author

    I'm still confused. It's dead-on by default. What is there to code? Is it the icons that muck it all up? I don't understand.

  19. dorkbox commented on Jul 6, 2017

    @dorkbox
    Owner

    The icons muck it all up.

  20. tresf commented on Jul 6, 2017

    @tresf
    Author

    The icons muck it all up.

    Will the library just leave the artwork at its default size? I think this is livable for now.

  21. dorkbox commented on Jul 6, 2017

    @dorkbox
    Owner

    The SystemTray.AUTO_SIZE=false; parameter will keep all artwork at it's provided size. There are 2 more API's added, SystemTray.getTrayImageSize() and SystemTray.getMenuImageSize().

    For getting the tray/menu image sizes...

    • MacOS is done (Apple hardcoded the values)
    • Linux menu sizes are done, WIP for the tray size (themes and DE's can change it).
    • Windows Tray size is almost done (it's also hardcoded, just regression testing all versions), and menu sizes are all over the place.

    For swing, the logic you figured out (from #45 (comment)) works most of the time, but not for Windows 8.1+ at different DPIs, and to get the actual icon size (as far as I can tell) for the context menu requires jumping into native code. There is already a BSD licensed JNA windows tray implementation, so it's going very, very quickly to add that functionality.

    I've decided to do this because now that the size is no longer hardcoded (it is now getting the largest image size possible before changing the menu size), means that at different DPIs there are pretty different menu heights, which really sticks out from the other menus.

    There have been several other issues fixed (one was a race condition for Swing menus), and the other is the checkmark menu entries getting offset in Ubuntu (#42). I'll mark that issue fixed once the code has been pushed and it's verified.

  22. tresf commented on Jul 7, 2017

    @tresf
    Author

    works most of the time, but not for Windows 8.1+ at different DPIs, and to get the actual icon size (as far as I can tell)

    So you're coding for an edge-case (HiDPI) on and edge-case (Windows 8.1) to avoid what Java has already done? Isn't this overkill?

  23. dorkbox commented on Jul 7, 2017

    @dorkbox
    Owner

    So you're coding for an edge-case (HiDPI) on and edge-case (Windows 8.1) to avoid what Java has already done? Isn't this overkill?

    I don't want to any edge-case stuff, because that would be close to impossible (and overkill) because different themes and settings can change the menu size.

  24. dorkbox commented on Jul 12, 2017

    @dorkbox
    Owner

    No edge cases necessary, I found the correct API to get the tray/menu correct image size.

  25. added this to the 3.2 milestone on Jul 12, 2017
  26. dorkbox commented on Jul 22, 2017

    @dorkbox
    Owner

    This (and some-what related issues) are fixed here:
    Windows XP: 2eea54b (for this issue)
    Windows (General): 2ca5cdf

    The system, if AUTO_SIZE=true (the default), will automatically resize all icons to what is reported via native methods, the idea being that a single 64x64 image can be provided, then be downsized as applicable. Regardless of AUTO_SIZE, one can always get the correct tray/menu image size via SystemTray.getTrayImageSize() and SystemTray.getMenuImageSize(), after SystemTray.get() has been called, but before any images have been assigned to the tray/menu. Of important note, not all versions of Windows have the same image size (it depends on the current theme applied), as is the same for Linux. MacOSX will always have the same image size (based on DPI settings).

    Additionally, HiDPI settings are also accounted for, so whatever the reported image size, is the correct image size for the DPI applied. There are "per-monitor" settings for Windows 8.1+, and it is not particularly easy to determine multiple screens and which screen the system tray is on. The overall DPI will be used based on windows handler in which the Java app is launched. I've found that this usually is correct since I'm querying windows directly for what image size to use.

    I will post post test/beta jars for validation before the 3.2 release, as image sizes greatly rely on the underlying hardware/software configuration, and should should be fully resolved before release.

  27. dorkbox commented on Jul 23, 2017

    @dorkbox
    Owner

    @tresf I've pushed the beta "all in one jar" for testing, if you'd like to verify this issue is resolved for you. Once I hear from you, I'll close this issue and release 3.2

  28. tresf commented on Jul 23, 2017

    @tresf
    Author

    @dorkbox we'd be happy to test, but we can't go live without tooltips (#50), so we'd have to split our code for Windows and Mac.

  29. dorkbox commented on Jul 23, 2017

    @dorkbox
    Owner

    Hm. Alright, I'll add tooltips. :)

  30. dorkbox commented on Aug 24, 2017

    @dorkbox
    Owner

    Release 3.2 is out, with added tooltips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions