mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 23:37:13 -06:00
PopupMenu on macOS: enabled drop shadows for popup menus and combobox popups (issue #94)
This commit is contained in:
@@ -20,6 +20,7 @@ FlatLaf Change Log
|
|||||||
and right margins. (issue #54)
|
and right margins. (issue #54)
|
||||||
- Hide mnemonics if window is deactivated (e.g. <kbd>Alt+Tab</kbd> to another
|
- Hide mnemonics if window is deactivated (e.g. <kbd>Alt+Tab</kbd> to another
|
||||||
window). (issue #43)
|
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
|
- macOS: Fixed NPE if using `JMenuBar` in `JInternalFrame` and macOS screen menu
|
||||||
bar is enabled (with `-Dapple.laf.useScreenMenuBar=true`). (issue #90)
|
bar is enabled (with `-Dapple.laf.useScreenMenuBar=true`). (issue #90)
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.formdev.flatlaf.ui;
|
|||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicPopupMenuUI;
|
import javax.swing.plaf.basic.BasicPopupMenuUI;
|
||||||
|
import com.formdev.flatlaf.util.SystemInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the Flat LaF UI delegate for {@link javax.swing.JPopupMenu}.
|
* Provides the Flat LaF UI delegate for {@link javax.swing.JPopupMenu}.
|
||||||
@@ -35,7 +36,28 @@ import javax.swing.plaf.basic.BasicPopupMenuUI;
|
|||||||
public class FlatPopupMenuUI
|
public class FlatPopupMenuUI
|
||||||
extends BasicPopupMenuUI
|
extends BasicPopupMenuUI
|
||||||
{
|
{
|
||||||
|
private boolean oldLightWeightPopupEnabled;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatPopupMenuUI();
|
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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user