mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
Menus: menu items now have larger left and right margins
This commit is contained in:
@@ -7,6 +7,7 @@ FlatLaf Change Log
|
|||||||
- Changed menu bar and popup menu background colors (made brighter in light
|
- Changed menu bar and popup menu background colors (made brighter in light
|
||||||
themes and darker in dark themes).
|
themes and darker in dark themes).
|
||||||
- Popup menus now have empty space at the top and bottom.
|
- Popup menus now have empty space at the top and bottom.
|
||||||
|
- Menu items now have larger left and right margins.
|
||||||
- Made `JMenu`, `JMenuItem`, `JCheckBoxMenuItem` and `JRadioButtonMenuItem`
|
- Made `JMenu`, `JMenuItem`, `JCheckBoxMenuItem` and `JRadioButtonMenuItem`
|
||||||
non-opaque.
|
non-opaque.
|
||||||
- TextField, FormattedTextField and PasswordField: Select all text when a text
|
- TextField, FormattedTextField and PasswordField: Select all text when a text
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 FormDev Software GmbH
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
|
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border for {@link javax.swing.JMenu}, {@link javax.swing.JMenuItem},
|
||||||
|
* {@link javax.swing.JCheckBoxMenuItem} and {@link javax.swing.JRadioButtonMenuItem}.
|
||||||
|
*
|
||||||
|
* @uiDefault MenuBar.itemMargins Insets
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public class FlatMenuItemBorder
|
||||||
|
extends FlatMarginBorder
|
||||||
|
{
|
||||||
|
private final Insets menuBarItemMargins = UIManager.getInsets( "MenuBar.itemMargins" );
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Insets getBorderInsets( Component c, Insets insets ) {
|
||||||
|
if( c.getParent() instanceof JMenuBar ) {
|
||||||
|
insets.top = scale( menuBarItemMargins.top );
|
||||||
|
insets.left = scale( menuBarItemMargins.left );
|
||||||
|
insets.bottom = scale( menuBarItemMargins.bottom + 1 );
|
||||||
|
insets.right = scale( menuBarItemMargins.right );
|
||||||
|
return insets;
|
||||||
|
} else
|
||||||
|
return super.getBorderInsets( c, insets );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,6 +59,7 @@ ViewportUI=com.formdev.flatlaf.ui.FlatViewportUI
|
|||||||
#---- variables ----
|
#---- variables ----
|
||||||
|
|
||||||
@textComponentMargin=2,6,2,6
|
@textComponentMargin=2,6,2,6
|
||||||
|
@menuItemMargin=2,8,2,8
|
||||||
|
|
||||||
|
|
||||||
#---- system colors ----
|
#---- system colors ----
|
||||||
@@ -117,10 +118,10 @@ CheckBox.rollover=true
|
|||||||
|
|
||||||
#---- CheckBoxMenuItem ----
|
#---- CheckBoxMenuItem ----
|
||||||
|
|
||||||
CheckBoxMenuItem.border=com.formdev.flatlaf.ui.FlatMarginBorder
|
CheckBoxMenuItem.border=com.formdev.flatlaf.ui.FlatMenuItemBorder
|
||||||
CheckBoxMenuItem.checkIcon=com.formdev.flatlaf.icons.FlatCheckBoxMenuItemIcon
|
CheckBoxMenuItem.checkIcon=com.formdev.flatlaf.icons.FlatCheckBoxMenuItemIcon
|
||||||
CheckBoxMenuItem.arrowIcon=com.formdev.flatlaf.icons.FlatMenuItemArrowIcon
|
CheckBoxMenuItem.arrowIcon=com.formdev.flatlaf.icons.FlatMenuItemArrowIcon
|
||||||
CheckBoxMenuItem.margin=2,2,2,2
|
CheckBoxMenuItem.margin=@menuItemMargin
|
||||||
CheckBoxMenuItem.opaque=false
|
CheckBoxMenuItem.opaque=false
|
||||||
CheckBoxMenuItem.background=@menuBackground
|
CheckBoxMenuItem.background=@menuBackground
|
||||||
|
|
||||||
@@ -214,9 +215,9 @@ List.dropLineColor=@dropLineColor
|
|||||||
|
|
||||||
#---- Menu ----
|
#---- Menu ----
|
||||||
|
|
||||||
Menu.border=com.formdev.flatlaf.ui.FlatMarginBorder
|
Menu.border=com.formdev.flatlaf.ui.FlatMenuItemBorder
|
||||||
Menu.arrowIcon=com.formdev.flatlaf.icons.FlatMenuArrowIcon
|
Menu.arrowIcon=com.formdev.flatlaf.icons.FlatMenuArrowIcon
|
||||||
Menu.margin=2,2,2,2
|
Menu.margin=@menuItemMargin
|
||||||
Menu.submenuPopupOffsetX={scaledInteger}-4
|
Menu.submenuPopupOffsetX={scaledInteger}-4
|
||||||
Menu.submenuPopupOffsetY={scaledInteger}-4
|
Menu.submenuPopupOffsetY={scaledInteger}-4
|
||||||
Menu.opaque=false
|
Menu.opaque=false
|
||||||
@@ -227,13 +228,14 @@ Menu.background=@menuBackground
|
|||||||
|
|
||||||
MenuBar.border=com.formdev.flatlaf.ui.FlatMenuBarBorder
|
MenuBar.border=com.formdev.flatlaf.ui.FlatMenuBarBorder
|
||||||
MenuBar.background=@menuBackground
|
MenuBar.background=@menuBackground
|
||||||
|
MenuBar.itemMargins=3,3,3,3
|
||||||
|
|
||||||
|
|
||||||
#---- MenuItem ----
|
#---- MenuItem ----
|
||||||
|
|
||||||
MenuItem.border=com.formdev.flatlaf.ui.FlatMarginBorder
|
MenuItem.border=com.formdev.flatlaf.ui.FlatMenuItemBorder
|
||||||
MenuItem.arrowIcon=com.formdev.flatlaf.icons.FlatMenuItemArrowIcon
|
MenuItem.arrowIcon=com.formdev.flatlaf.icons.FlatMenuItemArrowIcon
|
||||||
MenuItem.margin=2,2,2,2
|
MenuItem.margin=@menuItemMargin
|
||||||
MenuItem.opaque=false
|
MenuItem.opaque=false
|
||||||
MenuItem.background=@menuBackground
|
MenuItem.background=@menuBackground
|
||||||
|
|
||||||
@@ -303,10 +305,10 @@ RadioButton.rollover=true
|
|||||||
|
|
||||||
#---- RadioButtonMenuItem ----
|
#---- RadioButtonMenuItem ----
|
||||||
|
|
||||||
RadioButtonMenuItem.border=com.formdev.flatlaf.ui.FlatMarginBorder
|
RadioButtonMenuItem.border=com.formdev.flatlaf.ui.FlatMenuItemBorder
|
||||||
RadioButtonMenuItem.checkIcon=com.formdev.flatlaf.icons.FlatRadioButtonMenuItemIcon
|
RadioButtonMenuItem.checkIcon=com.formdev.flatlaf.icons.FlatRadioButtonMenuItemIcon
|
||||||
RadioButtonMenuItem.arrowIcon=com.formdev.flatlaf.icons.FlatMenuItemArrowIcon
|
RadioButtonMenuItem.arrowIcon=com.formdev.flatlaf.icons.FlatMenuItemArrowIcon
|
||||||
RadioButtonMenuItem.margin=2,2,2,2
|
RadioButtonMenuItem.margin=@menuItemMargin
|
||||||
RadioButtonMenuItem.opaque=false
|
RadioButtonMenuItem.opaque=false
|
||||||
RadioButtonMenuItem.background=@menuBackground
|
RadioButtonMenuItem.background=@menuBackground
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user