mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
Menus: support "underline" menu selection type (suggested in issue #49)
This commit is contained in:
@@ -23,6 +23,7 @@ import java.awt.Graphics;
|
||||
import java.awt.event.*;
|
||||
import java.util.function.Supplier;
|
||||
import javax.swing.*;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
import net.miginfocom.swing.*;
|
||||
|
||||
@@ -61,6 +62,11 @@ public class FlatMenusTest
|
||||
}
|
||||
}
|
||||
|
||||
private void underlineChanged() {
|
||||
UIManager.put( "MenuItem.selectionType", underlineCheckBox.isSelected() ? "underline" : null );
|
||||
FlatLaf.updateUI();
|
||||
}
|
||||
|
||||
private void showPopupMenuButtonActionPerformed(ActionEvent e) {
|
||||
Component invoker = (Component) e.getSource();
|
||||
PopupMenu popupMenu = new PopupMenu();
|
||||
@@ -193,6 +199,7 @@ public class FlatMenusTest
|
||||
JLabel popupMenuLabel = new JLabel();
|
||||
JButton showPopupMenuButton = new JButton();
|
||||
armedCheckBox = new JCheckBox();
|
||||
underlineCheckBox = new JCheckBox();
|
||||
|
||||
//======== this ========
|
||||
setLayout(new MigLayout(
|
||||
@@ -207,6 +214,7 @@ public class FlatMenusTest
|
||||
"[]" +
|
||||
"[top]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//---- menuBarLabel ----
|
||||
@@ -691,6 +699,11 @@ public class FlatMenusTest
|
||||
armedCheckBox.addActionListener(e -> armedChanged());
|
||||
add(armedCheckBox, "cell 0 3");
|
||||
|
||||
//---- underlineCheckBox ----
|
||||
underlineCheckBox.setText("underline menu selection");
|
||||
underlineCheckBox.addActionListener(e -> underlineChanged());
|
||||
add(underlineCheckBox, "cell 0 4 2 1");
|
||||
|
||||
//---- buttonGroup1 ----
|
||||
ButtonGroup buttonGroup1 = new ButtonGroup();
|
||||
buttonGroup1.add(radioButtonMenuItem5);
|
||||
@@ -708,6 +721,7 @@ public class FlatMenusTest
|
||||
private JCheckBox largerCheckBox;
|
||||
private JCheckBox accelCheckBox;
|
||||
private JCheckBox armedCheckBox;
|
||||
private JCheckBox underlineCheckBox;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
|
||||
//---- class PopupMenu ----------------------------------------------------
|
||||
|
||||
@@ -9,7 +9,7 @@ new FormModel {
|
||||
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
|
||||
"$columnConstraints": "[125][][][][]"
|
||||
"$rowConstraints": "[][top][][]"
|
||||
"$rowConstraints": "[][top][][][]"
|
||||
} ) {
|
||||
name: "this"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
@@ -528,6 +528,16 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "underlineCheckBox"
|
||||
"text": "underline menu selection"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "underlineChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 4 2 1"
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 790, 380 )
|
||||
|
||||
@@ -527,6 +527,9 @@ MenuItem.selectionBackground #4b6eaf javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.selectionForeground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.textAcceleratorGap 24
|
||||
MenuItem.textArrowGap 8
|
||||
MenuItem.underlineSelectionBackground #484c4f javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.underlineSelectionColor #4a88c7 javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.underlineSelectionHeight 3
|
||||
|
||||
|
||||
#---- MenuItemCheckBox ----
|
||||
|
||||
@@ -526,6 +526,9 @@ MenuItem.selectionBackground #4b6eaf javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.selectionForeground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.textAcceleratorGap 24
|
||||
MenuItem.textArrowGap 8
|
||||
MenuItem.underlineSelectionBackground #484c4f javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.underlineSelectionColor #4a88c7 javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.underlineSelectionHeight 3
|
||||
|
||||
|
||||
#---- MenuItemCheckBox ----
|
||||
|
||||
@@ -529,6 +529,9 @@ MenuItem.selectionBackground #2675bf javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.selectionForeground #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.textAcceleratorGap 24
|
||||
MenuItem.textArrowGap 8
|
||||
MenuItem.underlineSelectionBackground #e6e6e6 javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.underlineSelectionColor #4083c9 javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.underlineSelectionHeight 3
|
||||
|
||||
|
||||
#---- MenuItemCheckBox ----
|
||||
|
||||
@@ -528,6 +528,9 @@ MenuItem.selectionBackground #2675bf javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.selectionForeground #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.textAcceleratorGap 24
|
||||
MenuItem.textArrowGap 8
|
||||
MenuItem.underlineSelectionBackground #e6e6e6 javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.underlineSelectionColor #4083c9 javax.swing.plaf.ColorUIResource [UI]
|
||||
MenuItem.underlineSelectionHeight 3
|
||||
|
||||
|
||||
#---- MenuItemCheckBox ----
|
||||
|
||||
Reference in New Issue
Block a user