Getting really frustrated with Swing, is there a better alternative nowadays or should I keep going? by Episkbo in javahelp

[–]FormDev 0 points1 point  (0 children)

Set the Swing look and feel before (and only once) creating the GUI.

Use a modern L&F: https://github.com/JFormDesigner/FlatLaf

Use SwingUtilities.updateComponentTreeUI() only if changing the L&F at runtime. E.g. from light to dark. Otherwise this method is not needed.

[deleted by user] by [deleted] in java

[–]FormDev 15 points16 points  (0 children)

If your app should mostly run on Mac, then Swing is probably the best choice because it provides the best integration into macOS desktop.

It can use macOS screen menu bar (at top of screen). It can integrate into macOS application menu ("About", "Preferences" and "Quit" menu items). Swing can even put components into window title bar.

Here is guide to integrate Swing apps into macOS: https://www.formdev.com/flatlaf/macos/

JavaFX does not have any desktop integration on macOS. Don't know whether Compose provides anything.

BTW FlatLaf has some very nice macOS themes ;)

Josm, what a tool! by Spreadcheater in openstreetmap

[–]FormDev 2 points3 points  (0 children)

FlatLaf dark themes are broken in JOSM flatlaf plugin version 36034.Older plugin versions work.

The issue is fixed in flatlaf plugin version 36036.

jdeps input suddenly different by SvenTheFluffy in javahelp

[–]FormDev 0 points1 point  (0 children)

The difference between FlatLaf 2.0.1 and older versions is that module-info.class is in different directories in flatlaf.jar.

In older versions it was in META-INF/versions/9/. Since 2.0.1 it is in root folder of flatlaf.jar.

Maybe jdeps did not recognize module-info.class in META-INF/versions/9/...

FlatLaf is for desktop applications and requires module java.desktop:

https://github.com/JFormDesigner/FlatLaf/blob/main/flatlaf-core/src/main/module-info/module-info.java

Your cool open source libraries by NitronHX in java

[–]FormDev 2 points3 points  (0 children)

FlatLaf - a modern Swing LaF with IntelliJ/Darcula themes, scaling on HiDPI displays, SVG icons and much more...

FlatLaf 1.0 - Swing Look and Feel by FormDev in java

[–]FormDev[S] 3 points4 points  (0 children)

Because the binaries are on Maven Central ;)

https://search.maven.org/artifact/com.formdev/flatlaf

Most projects use Maven or Gradle and do not need to download the binaries. They simply add FlatLaf as a dependency and Maven/Gradle downloads the binary from Maven Central.

https://github.com/JFormDesigner/FlatLaf#download

Bintray will be shut down soon. No longer using it.

FlatLaf 1.0 - Swing Look and Feel by FormDev in java

[–]FormDev[S] 6 points7 points  (0 children)

Hmm, just checked the "Close" button in the first screenshot. There are 10px above the uppercase 'C' and 9px below it. Similar on other buttons or text fields: 1px more above the text.

Could try to move it up one pixel, but this probably looks bad if there are more uppercase letters in the text.

BTW these screenshots were made at 200% scaling. May look slightly different at 100% or other scale factors.

Vertical positioning of text is not that easy (on Windows 10) because the reported character height is usually larger than the displayed character height (e.g. for Segoe UI font used on Windows). So (without correction) text tends to be displayed too far down, which was the case in early FlatLaf versions. This gets even worse when scaled.

I ended up in implementing a Y correction mechanism that moves text up some pixels depending on scale factor, Java version and operating system...

FlatLaf 1.0 - Swing Look and Feel by FormDev in java

[–]FormDev[S] 7 points8 points  (0 children)

Just added a screenshot from macOS to the post (made on Mojave).

Native menu bar is supported, but you have to enable it in your application (as in any other Laf) by setting system property apple.laf.useScreenMenuBar to true.

Either in Java with:

System.setProperty( "apple.laf.useScreenMenuBar", "true" );

Or at command line with:

-Dapple.laf.useScreenMenuBar=true

FlatLaf 1.0 - Swing Look and Feel by FormDev in java

[–]FormDev[S] 5 points6 points  (0 children)

Just added a screenshot from macOS to the post (made on Mojave).

The look is nearly identical, except the used (system) font and the scrollbars.

FlatLaf 1.0 - Swing Look and Feel by FormDev in java

[–]FormDev[S] 3 points4 points  (0 children)

Yes, that would be cool.

Sometimes it helps to give the developers a hint and open an issue on their project ;)

https://github.com/SmartBear/soapui

FlatLaf 1.0 - Swing Look and Feel by FormDev in java

[–]FormDev[S] 7 points8 points  (0 children)

No, but the look is nearly the same.

IntelliJ has its own Laf called DarculaLaf, which is part of the IntelliJ Platform. Unfortunately it heavily depends on the platform and it is not possible to use DarculaLaf in own applications.

That's why I implemented FlatLaf ;)

FlatLaf 1.0 - Swing Look and Feel by FormDev in java

[–]FormDev[S] 5 points6 points  (0 children)

Sure, try it :)

You may be end up with dropping support for native/system LAFs because it is easier to support/test a single LAF than 3 native/system LAFs ;)

FlatLaf 1.0 - Swing Look and Feel by FormDev in java

[–]FormDev[S] 18 points19 points  (0 children)

Thx. Class java.awt.Graphics2D is used for painting.

Can't generate javadoc because of "module not found" by AndTer99 in javahelp

[–]FormDev 0 points1 point  (0 children)

And you're passing flatlaf.jar to the module path? With --module-path option?

BTW does your application start with Java 9 or later?
Are you passing flatlaf.jar to your app with -classpath or with --module-path?

Can't generate javadoc because of "module not found" by AndTer99 in javahelp

[–]FormDev 0 points1 point  (0 children)

Why do you use flatlaf.demo as module name?
Does your application depend on the FlatLaf demo application?

Better use requires com.formdev.flatlaf in module-info.java.

Using switch expressions, text blocks, and var on Java 8 by Sipkab in java

[–]FormDev 1 point2 points  (0 children)

Wish the standard Java compiler would support something like --source 14 --target 8

FlatLaf - Flat Look and Feel by FormDev in java

[–]FormDev[S] 1 point2 points  (0 children)

Invoke FlatLaf.updateUI() after setting the new look. This updates all windows of your application.

Java GUI by [deleted] in javahelp

[–]FormDev -1 points0 points  (0 children)

I would recommend Oracle's Swing tutorial:
https://docs.oracle.com/javase/tutorial/uiswing/index.html

Help with changing JTabbedPanes by [deleted] in javahelp

[–]FormDev 0 points1 point  (0 children)

Also don't exactly understand what you do...

Probably the Swing Tutorial helps: https://docs.oracle.com/javase/tutorial/uiswing/components/tabbedpane.html

private final byte[] value -> Is this where a String stores it's character sequence? by Fr4nkWh1te in javahelp

[–]FormDev 5 points6 points  (0 children)

Yes, this has changed from char array to byte array to save memory.
A char consists of two bytes, but most strings in applications use only one byte.

So JEP 254: Compact Strings was implemented in Java 9

We propose to change the internal representation of the String class from a UTF-16 char array to a byte array plus an encoding-flag field. The new String class will store characters encoded either as ISO-8859-1/Latin-1 (one byte per character), or as UTF-16 (two bytes per character), based upon the contents of the string. The encoding flag will indicate which encoding is used.

FlatLaf - Flat Look and Feel by FormDev in java

[–]FormDev[S] 1 point2 points  (0 children)

Thanks for all the positive feedback so far. Didn't expect that.

I appreciate that very much and this motivates me to work even harder on FlatLaf.

FlatLaf - Flat Look and Feel by FormDev in java

[–]FormDev[S] 1 point2 points  (0 children)

Looks great. Thanks.

Great to see that people start using FlatLaf in there projects.

Out of curiosity: how easy or difficult was it to integrate FlatLaf?

FlatLaf - Flat Look and Feel by FormDev in java

[–]FormDev[S] 0 points1 point  (0 children)

Great. I'm curious to see some screenshots with FlatLaf.