mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 06:57:13 -06:00
MenuBar:
- use derived colors for menu bar hover - use derived colors for menu item selected background - top-level JMenu now uses foreground color from parent JMenuBar This allows changing menu bar background to dark with: UIManager.put( "MenuBar.background", Color.DARK_GRAY ); UIManager.put( "MenuBar.foreground", Color.WHITE ); or menuBar.setBackground( Color.DARK_GRAY ); menuBar.setForeground( Color.WHITE ); (issue #117)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.formdev.flatlaf.testing;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
@@ -23,6 +24,7 @@ import java.awt.Graphics;
|
||||
import java.awt.event.*;
|
||||
import java.util.function.Supplier;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
import net.miginfocom.swing.*;
|
||||
@@ -69,6 +71,13 @@ public class FlatMenusTest
|
||||
FlatLaf.updateUI();
|
||||
}
|
||||
|
||||
private void popupMenubackgroundChanged() {
|
||||
UIManager.put( "PopupMenu.background", popupMenubackgroundCheckBox.isSelected()
|
||||
? new ColorUIResource( Color.yellow )
|
||||
: null );
|
||||
FlatLaf.updateUI();
|
||||
}
|
||||
|
||||
private void showPopupMenuButtonActionPerformed(ActionEvent e) {
|
||||
Component invoker = (Component) e.getSource();
|
||||
PopupMenu popupMenu = new PopupMenu();
|
||||
@@ -207,6 +216,7 @@ public class FlatMenusTest
|
||||
JButton showPopupMenuButton = new JButton();
|
||||
armedCheckBox = new JCheckBox();
|
||||
underlineCheckBox = new JCheckBox();
|
||||
popupMenubackgroundCheckBox = new JCheckBox();
|
||||
|
||||
//======== this ========
|
||||
setLayout(new MigLayout(
|
||||
@@ -222,6 +232,7 @@ public class FlatMenusTest
|
||||
"[top]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//---- menuBarLabel ----
|
||||
@@ -738,6 +749,11 @@ public class FlatMenusTest
|
||||
underlineCheckBox.addActionListener(e -> underlineChanged());
|
||||
add(underlineCheckBox, "cell 0 4 2 1");
|
||||
|
||||
//---- popupMenubackgroundCheckBox ----
|
||||
popupMenubackgroundCheckBox.setText("yellow popup menu background");
|
||||
popupMenubackgroundCheckBox.addActionListener(e -> popupMenubackgroundChanged());
|
||||
add(popupMenubackgroundCheckBox, "cell 0 5 2 1");
|
||||
|
||||
//---- buttonGroup1 ----
|
||||
ButtonGroup buttonGroup1 = new ButtonGroup();
|
||||
buttonGroup1.add(radioButtonMenuItem5);
|
||||
@@ -756,6 +772,7 @@ public class FlatMenusTest
|
||||
private JCheckBox accelCheckBox;
|
||||
private JCheckBox armedCheckBox;
|
||||
private JCheckBox underlineCheckBox;
|
||||
private JCheckBox popupMenubackgroundCheckBox;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
|
||||
//---- class PopupMenu ----------------------------------------------------
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
JFDML JFormDesigner: "7.0.1.0.272" Java: "13.0.2" encoding: "UTF-8"
|
||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "14" encoding: "UTF-8"
|
||||
|
||||
new FormModel {
|
||||
contentType: "form/swing"
|
||||
@@ -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" ) {
|
||||
@@ -561,6 +561,16 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 4 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "popupMenubackgroundCheckBox"
|
||||
"text": "yellow popup menu background"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "popupMenubackgroundChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 5 2 1"
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 790, 380 )
|
||||
|
||||
Reference in New Issue
Block a user