From d72cfc37d68968bfdd2048e68ef6f89883bf5f49 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Fri, 15 Nov 2019 18:24:22 +0100 Subject: [PATCH] fixed jittery submenu rendering on Mac (issue #10) --- CHANGELOG.md | 1 + flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e46fcc7..58310336 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ FlatLaf Change Log - Support using IntelliJ platform themes (.theme.json files). - Fixed selection background of checkbox in table cell. +- Fixed jittery submenu rendering on Mac. (issue #10) ## 0.18 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java index 86b2482a..8463898b 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java @@ -33,6 +33,7 @@ import javax.swing.AbstractButton; import javax.swing.JLabel; import javax.swing.JTabbedPane; import javax.swing.LookAndFeel; +import javax.swing.PopupFactory; import javax.swing.SwingUtilities; import javax.swing.UIDefaults; import javax.swing.UIManager; @@ -92,6 +93,11 @@ public abstract class FlatLaf super.initialize(); + // make sure that a plain popup factory is used (otherwise sub-menu rendering + // is "jittery" on Mac, where AquaLookAndFeel installs its own popup factory) + if( PopupFactory.getSharedInstance().getClass() != PopupFactory.class ) + PopupFactory.setSharedInstance( new PopupFactory() ); + // add mnemonic listener mnemonicListener = e -> { if( e.getKeyCode() == KeyEvent.VK_ALT )