MenuBar.underlineSelectionColor

This commit is contained in:
mmatessi
2020-11-27 19:14:28 +01:00
parent 21a12b8dd4
commit f149d2b7cd
3 changed files with 9 additions and 5 deletions

View File

@@ -246,7 +246,7 @@ public class FlatMenuItemRenderer
g.setColor( Color.orange ); g.drawRect( arrowRect.x, arrowRect.y, arrowRect.width - 1, arrowRect.height - 1 );
debug*/
paintBackground( g, selectionBackground );
paintBackground( g, selectionBackground, underlineSelectionColor );
paintIcon( g, iconRect, getIconForPainting() );
paintText( g, textRect, menuItem.getText(), selectionForeground, disabledForeground );
paintAccelerator( g, accelRect, getAcceleratorText(), acceleratorForeground, acceleratorSelectionForeground, disabledForeground );
@@ -254,7 +254,7 @@ debug*/
paintArrowIcon( g, arrowRect, arrowIcon );
}
protected void paintBackground( Graphics g, Color selectionBackground ) {
protected void paintBackground( Graphics g, Color selectionBackground, Color underlineSelectionColor ) {
boolean armedOrSelected = isArmedOrSelected( menuItem );
if( menuItem.isOpaque() || armedOrSelected ) {
int width = menuItem.getWidth();

View File

@@ -60,13 +60,16 @@ import javax.swing.plaf.basic.BasicMenuUI;
* <!-- FlatMenuUI -->
*
* @uiDefault MenuItem.iconTextGap int
* @uiDefault MenuBar.hoverBackground Color
* @uiDefault MenuBar.hoverBackground
* @uiDefault MenuBar.underlineSelectionColor Color
*
* @author Karl Tauber
*/
public class FlatMenuUI
extends BasicMenuUI
{
protected final Color menuBarUnderlineSelectionColor = UIManager.getColor( "MenuBar.underlineSelectionColor" );
private Color hoverBackground;
private FlatMenuItemRenderer renderer;
@@ -154,7 +157,7 @@ public class FlatMenuUI
}
@Override
protected void paintBackground( Graphics g, Color selectionBackground ) {
protected void paintBackground( Graphics g, Color selectionBackground, Color menuItemUnderlineSelectionColor ) {
ButtonModel model = menuItem.getModel();
if( model.isRollover() && !model.isArmed() && !model.isSelected() &&
model.isEnabled() && ((JMenu)menuItem).isTopLevelMenu() )
@@ -162,7 +165,7 @@ public class FlatMenuUI
g.setColor( deriveBackground( hoverBackground ) );
g.fillRect( 0, 0, menuItem.getWidth(), menuItem.getHeight() );
} else
super.paintBackground( g, selectionBackground );
super.paintBackground( g, selectionBackground, ((JMenu)menuItem).isTopLevelMenu() ? menuBarUnderlineSelectionColor : menuItemUnderlineSelectionColor );
}
}
}

View File

@@ -337,6 +337,7 @@ MenuBar.border=com.formdev.flatlaf.ui.FlatMenuBarBorder
MenuBar.background=@menuBackground
MenuBar.hoverBackground=@menuHoverBackground
MenuBar.itemMargins=3,8,3,8
MenuBar.underlineSelectionColor=$TabbedPane.underlineColor
#---- MenuItem ----