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