mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
MenuBar: top level menus now use MenuBar.font instead of Menu.font (issue #589)
This commit is contained in:
@@ -10,6 +10,8 @@ FlatLaf Change Log
|
||||
This gives FlatLaf windows a more "native" feeling. (issue #482)
|
||||
- MenuBar: Support different menu selection style UI defaults for `MenuBar` and
|
||||
`MenuItem`. (issue #587)
|
||||
- MenuBar: Top level menus now use `MenuBar.font` instead of `Menu.font`. (issue
|
||||
#589)
|
||||
- PasswordField: Reveal button is now hidden (and turned off) if password field
|
||||
is disabled. (issue #501)
|
||||
- TabbedPane: New option to disable tab run rotation in wrap layout. Set UI
|
||||
|
||||
@@ -97,6 +97,7 @@ public class FlatMenuItemRenderer
|
||||
@Styleable protected int underlineSelectionHeight = UIManager.getInt( "MenuItem.underlineSelectionHeight" );
|
||||
|
||||
private boolean iconsShared = true;
|
||||
private final Font menuFont = UIManager.getFont( "Menu.font" );
|
||||
|
||||
protected FlatMenuItemRenderer( JMenuItem menuItem, Icon checkIcon, Icon arrowIcon,
|
||||
Font acceleratorFont, String acceleratorDelimiter )
|
||||
@@ -193,7 +194,8 @@ public class FlatMenuItemRenderer
|
||||
|
||||
// layout icon and text
|
||||
SwingUtilities.layoutCompoundLabel( menuItem,
|
||||
menuItem.getFontMetrics( menuItem.getFont() ), menuItem.getText(), getIconForLayout(),
|
||||
menuItem.getFontMetrics( isTopLevelMenu ? getTopLevelFont() : menuItem.getFont() ),
|
||||
menuItem.getText(), getIconForLayout(),
|
||||
menuItem.getVerticalAlignment(), menuItem.getHorizontalAlignment(),
|
||||
menuItem.getVerticalTextPosition(), menuItem.getHorizontalTextPosition(),
|
||||
viewRect, iconRect, textRect, scale( menuItem.getIconTextGap() ) );
|
||||
@@ -295,7 +297,8 @@ public class FlatMenuItemRenderer
|
||||
|
||||
// layout icon and text
|
||||
SwingUtilities.layoutCompoundLabel( menuItem,
|
||||
menuItem.getFontMetrics( menuItem.getFont() ), menuItem.getText(), getIconForLayout(),
|
||||
menuItem.getFontMetrics( isTopLevelMenu ? getTopLevelFont() : menuItem.getFont() ),
|
||||
menuItem.getText(), getIconForLayout(),
|
||||
menuItem.getVerticalAlignment(), menuItem.getHorizontalAlignment(),
|
||||
menuItem.getVerticalTextPosition(), menuItem.getHorizontalTextPosition(),
|
||||
labelRect, iconRect, textRect, scale( menuItem.getIconTextGap() ) );
|
||||
@@ -405,9 +408,10 @@ debug*/
|
||||
}
|
||||
|
||||
int mnemonicIndex = FlatLaf.isShowMnemonics() ? menuItem.getDisplayedMnemonicIndex() : -1;
|
||||
Color foreground = (isTopLevelMenu( menuItem ) ? menuItem.getParent() : menuItem).getForeground();
|
||||
boolean isTopLevelMenu = isTopLevelMenu( menuItem );
|
||||
Color foreground = (isTopLevelMenu ? menuItem.getParent() : menuItem).getForeground();
|
||||
|
||||
paintText( g, menuItem, textRect, text, mnemonicIndex, menuItem.getFont(),
|
||||
paintText( g, menuItem, textRect, text, mnemonicIndex, isTopLevelMenu ? getTopLevelFont() : menuItem.getFont(),
|
||||
foreground, isUnderlineSelection() ? foreground : selectionForeground, disabledForeground );
|
||||
}
|
||||
|
||||
@@ -494,6 +498,11 @@ debug*/
|
||||
return "underline".equals( UIManager.getString( "MenuItem.selectionType" ) );
|
||||
}
|
||||
|
||||
private Font getTopLevelFont() {
|
||||
Font font = menuItem.getFont();
|
||||
return (font != menuFont) ? font : menuItem.getParent().getFont();
|
||||
}
|
||||
|
||||
private Icon getIconForPainting() {
|
||||
Icon icon = menuItem.getIcon();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user