question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

My testing app, which uses FlatLaf, is also run within WinPE.

I have noticed some quirks in WinPE which affect FlatLaf. Since this has been such a minor issue with an easy fix on my side (as well as a pretty rare use-case), I haven’t bothered filing a report about this stuff up until now.

If dealing with WinPE, is outside of your scope, I totally understand that.

The following comments about the frame and font issues are also within the code block (which I use in my app) that I have included below. There may be more efficient ways of checking for WinPE that I am not aware of as well.

Decorated Frame Issue: In WinPE, FlatLaf Decorated window looks funky (the default left, right, and bottom frames are still shown) and is unnecessary since the default style fits in better with WinPE than the Win 10 Decorated style. NOTE: Prior to FlatLaf 1.1, the whole Decorated frame was drawn correctly, but if the windows was minimized, it could not be restored back from the bottom of the screen when clicking the restore button in the titlebar. I double checked that behavior with FlatLaf 1.1 and that is no longer an issue. I suspect your recent work with a more with the native Decorated titlebar is what fixed that. Still, the default Windows style fits in better in WinPE.

Default Font Issue: The regular “Segoe” system font is not included by default (only bold and italic “Segoe” is included in WinPE), so font Font.PLAIN (when using “Segoe” system font) is rendered as bold, making all text bold. My solution has been to use “Tahoma” in WinPE instead since it is included by default, and looks good. It is possible to install “segoeui.ttf” into "\Windows\Fonts" in WinPE, but when I tried this it didn’t really render very well in WinPE, regular text still looked slightly bold and a little off and “Tahoma” looks better than “Segoe” did. “Microsoft Sans Serif” is also available in WinPE, and doesn’t look too bad, but I liked the look of “Tahoma” better (notaably the kerning and letter spacing of bold text).

I will try to grab some screenshots of these issues later today to show you if you don’t have easy access to WinPE.

if (isWindows) {
    Boolean isWindowsPE = ((new File("\\Windows\\System32\\startnet.cmd").exists() || new File("\\Windows\\System32\\winpeshl.ini").exists()) && !new CommandReader("reg query HKLM\\SYSTEM\\Setup /v FactoryPreInstallInProgress").getFirstOutputLineContaining("0x1").isEmpty());
    
    if (isWindowsPE) {
        // In WinPE, FlatLaf Decorated window looks funky (the default left, right, and bottom frames are still shown) and is unnecessary since the default style fits in better with WinPE than the Win 10 Decorated style.
        UIManager.put("TitlePane.useWindowDecorations", false);

        if ((defaultFont == null) || !defaultFont.getFamily().equals("Tahoma")) {
            if (new File("\\Windows\\Fonts\\tahoma.ttf").exists()) {
                // Use "Tahoma" in WinPE because the regular "Segoe" system font is not included by default (only bold and italic "Segoe" is included in WinPE), so font Font.PLAIN (when using "Segoe" system font) is rendered as bold, making all text bold.
                // It is possible to install "segoeui.ttf" into "\Windows\Fonts\" in WinPE, but when I tried this it didn't really render very well in WinPE, regular text still looked slightly bold and a little off and "Tahoma" looks better than "Segoe" did.
                // "Microsoft Sans Serif" is also available in WinPE, and doesn't look too bad, but I liked the look of "Tahoma" better (notaably the kerning and letter spacing of bold text).
                defaultFont = StyleContext.getDefaultStyleContext().getFont("Tahoma", ((defaultFont == null) ? Font.PLAIN : defaultFont.getStyle()), ((defaultFont == null) ? 12 : defaultFont.getSize()));
            } else if (defaultFont != null) {
                // If somehow "Tahoma" isn't available in WinPE (which should never actually happen), set default font to Font.ITALIC so there it at least some differentiation between intentionally bolded and "regular" text (which will now be italic).
                defaultFont = StyleContext.getDefaultStyleContext().getFont(defaultFont.getFamily(), Font.ITALIC, defaultFont.getSize());
            }
        }
    }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
DevCharlycommented, Mar 30, 2021

Thanks for the feedback. I’ve changed it in main branch.

1reaction
DevCharlycommented, Mar 26, 2021

Thx for the info.

FlatLaf now uses win.defaultGUI.font on WinPE, which is BTW the same desktop property that the Java Windows L&F uses.

Implemented in main branch and available in latest snapshot: https://github.com/JFormDesigner/FlatLaf#snapshots

FlatLaf 1.1.1 release follows the next days… Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FlatLaf - Flat Look and Feel | FormDev - JFormDesigner
FlatLaf is a modern open-source cross-platform Look and Feel for Java Swing desktop applications. It looks almost flat (no shadows or gradients), clean,...
Read more >
JFormDesigner/FlatLaf 1.1.1 on GitHub - NewReleases.io
This is a bug fix release. Users of version 1.1 are recommended to update to 1.1.1 . Change log. New features and improvements....
Read more >
Java Swing - How to install FlatLaf Look and Feel - YouTube
This is how to install flatlaf look and feel on java swingand how to install and download new themesThis is the beautiful look...
Read more >
FlatLaf Tutorial - How to custom ui with properties (Part 2)
Java Swing FlatLaf TutorialThis video I will show how to custom ui with properties file.▻ More Tutorial :▻ Animation Tutorial ...
Read more >
How to install flatlaf look and feel (Part 1) - YouTube
Java Swing FlatLaf TutorialThis video I will show how to install flatlaf look and feel to your project.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found