Top 10 Java Look-and-Feel (L&F) Libraries and How to Use Them
Below are ten popular Java Look-and-Feel libraries or approaches (both built-in and third-party), short descriptions, when to use each, and concise usage notes with example code snippets where appropriate.
| Library / Approach | Short description | When to use | Quick usage |
|---|---|---|---|
| 1. Metal (Default/Java) | Java’s cross-platform default L&F, highly stable and lightweight. | Use when you need maximum portability and no external deps. | java UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); |
| 2. Nimbus (Built-in modern L&F) | Modern, vector-friendly L&F bundled with Java 6u10+. Clean visuals and configurable defaults. | Use for a modern appearance without third-party libraries. | java UIManager.setLookAndFeel(“javax.swing.plaf.nimbus.NimbusLookAndFeel”); |
| 3. Windows / Windows Classic (Platform) | Native Windows appearance using platform L&F. | Use when you want apps to match Windows users’ expectations. | java UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
| 4. Synth (Skinnable via XML) | XML-driven, highly customizable skinnable L&F in Swing. | Use for entirely custom themes without third-party code. | SynthLookAndFeel synth = new SynthLookAndFeel(); synth.load(new FileInputStream(“theme.xml”)); UIManager.setLookAndFeel(synth); |
| 5. FlatLaf | Modern, flat, high-performance L&F inspired by IntelliJ’s UI; supports light/dark themes. | Use for contemporary apps, easy theming, and good performance. | UIManager.setLookAndFeel(new com.formdev.flatlaf.FlatLightLaf()); Add dependency: com.formdev:flatlaf |
| 6. Darcula (IntelliJ theme / FlatLaf plugin) | Dark theme option (originally IntelliJ); available as FlatLaf theme/plugin. | Use for dark-mode-focused UIs. | UIManager.setLookAndFeel(new com.formdev.flatlaf.intellijthemes.FlatAtomOneDarkIJTheme()); |
| 7. Substance | Feature-rich, skinnable L&F with many prebuilt skins (historically popular). | Use if you want many ready-made skins and advanced decoration features. | Add dependency and call: UIManager.setLookAndFeel(“org.pushingpixels.substance.api.skin.SubstanceGraphiteLookAndFeel”); |
| 8. JTattoo | Collection of several themes (Acryl, Aluminium, Bernstein, etc.) — easy to swap. | Use when you want multiple distinct themed looks quickly. | UIManager.setLookAndFeel(“com.jtattoo.plaf.acryl.AcrylLookAndFeel”); |
| 9. Quaqua (macOS-focused) | Native-like look for macOS (historical; best for older Swing apps targeting macOS). | Use if targeting macOS users and needing closer native feel (check compatibility). | Add Quaqua jar and set its L&F class. |
| 10. Custom UI delegates (pluggable) | Create custom LookAndFeel by implementing UI delegates (extends BasicLookAndFeel or Synth). | Use for complete control over component rendering and behavior. | Create subclass of BasicLookAndFeel or use Synth XML and register with UIManager. |
How to choose
- Default/Portable: Metal or Nimbus.
- Native matching: UIManager.getSystemLookAndFeelClassName().
- Modern/lightweight: FlatLaf (recommended today).
- Dark themes: Darcula/FlatLaf dark themes.
- Many skins out-of-the-box: JTattoo or Substance.
- Full customization: Synth or custom UI delegates.
Basic integration pattern (Swing)
- Add any required dependency (e.g., FlatLaf, JTattoo) to your build (Maven/Gradle) or include JAR.
- Set L&F before creating UI on Event Dispatch Thread (EDT).
- Create and show UI.
Example (thread-safe):
java
public static void main(String[] args) { try { UIManager.setLookAndFeel(new com.formdev.flatlaf.FlatLightLaf()); } catch (Exception ex) { ex.printStackTrace(); } SwingUtilities.invokeLater(() -> { JFrame frame = new JFrame(“Demo”); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JLabel(“Hello”)); frame.pack(); frame.setVisible(true); }); }
Common pitfalls
- Set L&F before creating Swing components.
- Some L&Fs may not support all components or behave differently; test dialogs, menus, tables.
- Keep dependencies up to date for compatibility with recent Java versions.
If you want, I can generate a sample Maven/Gradle configuration for FlatLaf, example themes, or a small demo app that lets users pick between these L&Fs at runtime.
Leave a Reply