Skip to content

Commit

Permalink
PopupMenu on macOS: enabled drop shadows for popup menus and combobox…
Browse files Browse the repository at this point in the history
… popups (issue #94)
  • Loading branch information
DevCharly committed May 5, 2020
1 parent b228dbb commit 27a347d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ FlatLaf Change Log
and right margins. (issue #54)
- Hide mnemonics if window is deactivated (e.g. <kbd>Alt+Tab</kbd> to another
window). (issue #43)
- macOS: Enabled drop shadows for popup menus and combobox popups. (issue #94)
- macOS: Fixed NPE if using `JMenuBar` in `JInternalFrame` and macOS screen menu
bar is enabled (with `-Dapple.laf.useScreenMenuBar=true`). (issue #90)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicPopupMenuUI;
import com.formdev.flatlaf.util.SystemInfo;

/**
* Provides the Flat LaF UI delegate for {@link javax.swing.JPopupMenu}.
Expand All @@ -35,7 +36,28 @@
public class FlatPopupMenuUI
extends BasicPopupMenuUI
{
private boolean oldLightWeightPopupEnabled;

public static ComponentUI createUI( JComponent c ) {
return new FlatPopupMenuUI();
}

@Override
public void installDefaults() {
super.installDefaults();

// use heavy-weight popups on macOS to get nice drop shadow from OS
if( SystemInfo.IS_MAC ) {
oldLightWeightPopupEnabled = popupMenu.isLightWeightPopupEnabled();
popupMenu.setLightWeightPopupEnabled( false );
}
}

@Override
protected void uninstallDefaults() {
super.uninstallDefaults();

if( SystemInfo.IS_MAC )
popupMenu.setLightWeightPopupEnabled( oldLightWeightPopupEnabled );
}
}

0 comments on commit 27a347d

Please sign in to comment.