mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 22:40:53 +03:00
Menu: fixed missing background on hover if top-level JMenu is opaque and selectionInsets or selectionArc are set (PR #536)
This commit is contained in:
@@ -251,6 +251,8 @@ public class FlatMenuUI
|
||||
/** @since 3 */
|
||||
@Override
|
||||
protected void paintBackground( Graphics g ) {
|
||||
super.paintBackground( g );
|
||||
|
||||
if( ((JMenu)menuItem).isTopLevelMenu() && isHover() ) {
|
||||
// paint hover background
|
||||
Color color = deriveBackground( getStyleFromMenuBarUI( ui -> ui.hoverBackground, hoverBackground ) );
|
||||
@@ -259,10 +261,7 @@ public class FlatMenuUI
|
||||
g.fillRect( 0, 0, menuItem.getWidth(), menuItem.getHeight() );
|
||||
} else
|
||||
paintSelection( g, color, selectionInsets, selectionArc );
|
||||
return;
|
||||
}
|
||||
|
||||
super.paintBackground( g );
|
||||
}
|
||||
|
||||
/** @since 3 */
|
||||
@@ -289,14 +288,6 @@ public class FlatMenuUI
|
||||
super.paintSelection( g, selectionBackground, selectionInsets, selectionArc );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintText( Graphics g, Rectangle textRect, String text, Color selectionForeground, Color disabledForeground ) {
|
||||
if( ((JMenu)menuItem).isTopLevelMenu() && !isUnderlineSelection() )
|
||||
selectionForeground = getStyleFromMenuBarUI( ui -> ui.selectionForeground, menuBarSelectionForeground, selectionForeground );
|
||||
|
||||
super.paintText( g, textRect, text, selectionForeground, disabledForeground );
|
||||
}
|
||||
|
||||
/** @since 3 */
|
||||
@Override
|
||||
protected void paintUnderlineSelection( Graphics g, Color underlineSelectionBackground,
|
||||
@@ -312,6 +303,14 @@ public class FlatMenuUI
|
||||
super.paintUnderlineSelection( g, underlineSelectionBackground, underlineSelectionColor, underlineSelectionHeight );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintText( Graphics g, Rectangle textRect, String text, Color selectionForeground, Color disabledForeground ) {
|
||||
if( ((JMenu)menuItem).isTopLevelMenu() && !isUnderlineSelection() )
|
||||
selectionForeground = getStyleFromMenuBarUI( ui -> ui.selectionForeground, menuBarSelectionForeground, selectionForeground );
|
||||
|
||||
super.paintText( g, textRect, text, selectionForeground, disabledForeground );
|
||||
}
|
||||
|
||||
private boolean isHover() {
|
||||
ButtonModel model = menuItem.getModel();
|
||||
return model.isRollover() && !model.isArmed() && !model.isSelected() && model.isEnabled();
|
||||
|
||||
Reference in New Issue
Block a user