mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 06:57:13 -06:00
Window decorations: embedded menu bar did not always respond to mouse events after adding menus and when running in JetBrains Runtime (issue #151)
This commit is contained in:
@@ -22,6 +22,7 @@ import java.awt.event.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import javax.swing.*;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
import net.miginfocom.swing.*;
|
||||
@@ -117,6 +118,32 @@ public class FlatWindowDecorationsTest
|
||||
rootPane.putClientProperty( FlatClientProperties.MENU_BAR_EMBEDDED, menuBarEmbeddedCheckBox.isSelected() );
|
||||
}
|
||||
|
||||
private void addMenu() {
|
||||
JMenu menu = new JMenu( "Hello" );
|
||||
menu.add( new JMenuItem( "world" ) );
|
||||
menuBar.add( menu );
|
||||
menuBar.revalidate();
|
||||
}
|
||||
|
||||
private void removeMenu() {
|
||||
int menuCount = menuBar.getMenuCount();
|
||||
if( menuCount <= 0 )
|
||||
return;
|
||||
|
||||
menuBar.remove( menuCount - 1 );
|
||||
menuBar.revalidate();
|
||||
}
|
||||
|
||||
private void changeMenu() {
|
||||
int menuCount = menuBar.getMenuCount();
|
||||
if( menuCount <= 0 )
|
||||
return;
|
||||
|
||||
int len = new Random().nextInt( 20 );
|
||||
String text = "1234567890abcdefghij".substring( 0, len + 1 );
|
||||
menuBar.getMenu( menuCount - 1 ).setText( text );
|
||||
}
|
||||
|
||||
private void resizableChanged() {
|
||||
Window window = SwingUtilities.windowForComponent( this );
|
||||
if( window instanceof Frame )
|
||||
@@ -218,6 +245,9 @@ public class FlatWindowDecorationsTest
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
menuBarCheckBox = new JCheckBox();
|
||||
JButton addMenuButton = new JButton();
|
||||
JButton removeMenuButton = new JButton();
|
||||
JButton changeMenuButton = new JButton();
|
||||
menuBarEmbeddedCheckBox = new JCheckBox();
|
||||
resizableCheckBox = new JCheckBox();
|
||||
maximizedBoundsCheckBox = new JCheckBox();
|
||||
@@ -271,7 +301,7 @@ public class FlatWindowDecorationsTest
|
||||
"ltr,insets dialog,hidemode 3",
|
||||
// columns
|
||||
"[left]para" +
|
||||
"[fill]",
|
||||
"[left]",
|
||||
// rows
|
||||
"para[]0" +
|
||||
"[]0" +
|
||||
@@ -287,6 +317,21 @@ public class FlatWindowDecorationsTest
|
||||
menuBarCheckBox.addActionListener(e -> menuBarChanged());
|
||||
add(menuBarCheckBox, "cell 0 0");
|
||||
|
||||
//---- addMenuButton ----
|
||||
addMenuButton.setText("Add menu");
|
||||
addMenuButton.addActionListener(e -> addMenu());
|
||||
add(addMenuButton, "cell 1 0 1 2,align left top,grow 0 0");
|
||||
|
||||
//---- removeMenuButton ----
|
||||
removeMenuButton.setText("Remove menu");
|
||||
removeMenuButton.addActionListener(e -> removeMenu());
|
||||
add(removeMenuButton, "cell 1 0 1 2,align left top,grow 0 0");
|
||||
|
||||
//---- changeMenuButton ----
|
||||
changeMenuButton.setText("Change menu");
|
||||
changeMenuButton.addActionListener(e -> changeMenu());
|
||||
add(changeMenuButton, "cell 1 0 1 2,align left top,grow 0 0");
|
||||
|
||||
//---- menuBarEmbeddedCheckBox ----
|
||||
menuBarEmbeddedCheckBox.setText("embedded menu bar");
|
||||
menuBarEmbeddedCheckBox.setSelected(true);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "13.0.2" encoding: "UTF-8"
|
||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "14" encoding: "UTF-8"
|
||||
|
||||
new FormModel {
|
||||
contentType: "form/swing"
|
||||
@@ -8,7 +8,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": "[left]para[fill]"
|
||||
"$columnConstraints": "[left]para[left]"
|
||||
"$rowConstraints": "para[]0[]0[]0[][][top][]"
|
||||
} ) {
|
||||
name: "this"
|
||||
@@ -23,6 +23,27 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "addMenuButton"
|
||||
"text": "Add menu"
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "addMenu", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0 1 2,align left top,grow 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "removeMenuButton"
|
||||
"text": "Remove menu"
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "removeMenu", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0 1 2,align left top,grow 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "changeMenuButton"
|
||||
"text": "Change menu"
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "changeMenu", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0 1 2,align left top,grow 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "menuBarEmbeddedCheckBox"
|
||||
"text": "embedded menu bar"
|
||||
@@ -238,7 +259,7 @@ new FormModel {
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 450, 380 )
|
||||
"size": new java.awt.Dimension( 550, 380 )
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JMenuBar", new FormLayoutManager( class javax.swing.JMenuBar ) ) {
|
||||
name: "menuBar"
|
||||
|
||||
Reference in New Issue
Block a user