Skip to content

Commit

Permalink
FlatWindowDecorationsTest: added "menu bar visible" checkbox (for tes…
Browse files Browse the repository at this point in the history
…ting previous commit)
  • Loading branch information
DevCharly committed Oct 14, 2020
1 parent 87f2acc commit 4b7ef6e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void addNotify() {
Window window = SwingUtilities.windowForComponent( this );
menuBarCheckBox.setEnabled( window instanceof JFrame );
menuBarEmbeddedCheckBox.setEnabled( window instanceof JFrame );
menuBarVisibleCheckBox.setEnabled( window instanceof JFrame );
maximizedBoundsCheckBox.setEnabled( window instanceof Frame );

addMenuButton.setEnabled( menuBarCheckBox.isEnabled() );
Expand Down Expand Up @@ -123,6 +124,10 @@ private void menuBarEmbeddedChanged() {
rootPane.putClientProperty( FlatClientProperties.MENU_BAR_EMBEDDED, menuBarEmbeddedCheckBox.isSelected() );
}

private void menuBarVisibleChanged() {
menuBar.setVisible( menuBarVisibleCheckBox.isSelected() );
}

private void addMenu() {
JMenu menu = new JMenu( "Hello" );
menu.add( new JMenuItem( "world" ) );
Expand Down Expand Up @@ -254,6 +259,7 @@ private void initComponents() {
removeMenuButton = new JButton();
changeMenuButton = new JButton();
menuBarEmbeddedCheckBox = new JCheckBox();
menuBarVisibleCheckBox = new JCheckBox();
resizableCheckBox = new JCheckBox();
maximizedBoundsCheckBox = new JCheckBox();
undecoratedCheckBox = new JCheckBox();
Expand Down Expand Up @@ -311,6 +317,7 @@ private void initComponents() {
"para[]0" +
"[]0" +
"[]0" +
"[]0" +
"[]" +
"[]" +
"[top]" +
Expand Down Expand Up @@ -343,29 +350,35 @@ private void initComponents() {
menuBarEmbeddedCheckBox.addActionListener(e -> menuBarEmbeddedChanged());
add(menuBarEmbeddedCheckBox, "cell 0 1");

//---- menuBarVisibleCheckBox ----
menuBarVisibleCheckBox.setText("menu bar visible");
menuBarVisibleCheckBox.setSelected(true);
menuBarVisibleCheckBox.addActionListener(e -> menuBarVisibleChanged());
add(menuBarVisibleCheckBox, "cell 0 2");

//---- resizableCheckBox ----
resizableCheckBox.setText("resizable");
resizableCheckBox.setSelected(true);
resizableCheckBox.addActionListener(e -> resizableChanged());
add(resizableCheckBox, "cell 0 2");
add(resizableCheckBox, "cell 0 3");

//---- maximizedBoundsCheckBox ----
maximizedBoundsCheckBox.setText("maximized bounds (50,100, 1000,700)");
maximizedBoundsCheckBox.addActionListener(e -> maximizedBoundsChanged());
add(maximizedBoundsCheckBox, "cell 1 2");
add(maximizedBoundsCheckBox, "cell 1 3");

//---- undecoratedCheckBox ----
undecoratedCheckBox.setText("undecorated");
undecoratedCheckBox.addActionListener(e -> undecoratedChanged());
add(undecoratedCheckBox, "cell 0 3");
add(undecoratedCheckBox, "cell 0 4");

//---- label1 ----
label1.setText("Style:");
add(label1, "cell 0 4");
add(label1, "cell 0 5");

//---- label2 ----
label2.setText("Icon:");
add(label2, "cell 1 4");
add(label2, "cell 1 5");

//======== panel1 ========
{
Expand Down Expand Up @@ -430,7 +443,7 @@ private void initComponents() {
styleFileChooserRadioButton.addActionListener(e -> decorationStyleChanged());
panel1.add(styleFileChooserRadioButton, "cell 0 8");
}
add(panel1, "cell 0 5");
add(panel1, "cell 0 6");

//======== panel2 ========
{
Expand Down Expand Up @@ -459,12 +472,12 @@ private void initComponents() {
iconTestRandomRadioButton.addActionListener(e -> iconChanged());
panel2.add(iconTestRandomRadioButton, "cell 0 2");
}
add(panel2, "cell 1 5");
add(panel2, "cell 1 6");

//---- openDialogButton ----
openDialogButton.setText("Open Dialog");
openDialogButton.addActionListener(e -> openDialog());
add(openDialogButton, "cell 0 6");
add(openDialogButton, "cell 0 7");

//======== menuBar ========
{
Expand Down Expand Up @@ -660,6 +673,7 @@ private void initComponents() {
private JButton removeMenuButton;
private JButton changeMenuButton;
private JCheckBox menuBarEmbeddedCheckBox;
private JCheckBox menuBarVisibleCheckBox;
private JCheckBox resizableCheckBox;
private JCheckBox maximizedBoundsCheckBox;
private JCheckBox undecoratedCheckBox;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.2.0.298" Java: "14" encoding: "UTF-8"
JFDML JFormDesigner: "7.0.2.0.298" Java: "15" encoding: "UTF-8"

new FormModel {
contentType: "form/swing"
Expand All @@ -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": "[left]para[left]"
"$rowConstraints": "para[]0[]0[]0[][][top][]"
"$rowConstraints": "para[]0[]0[]0[]0[][][top][]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JCheckBox" ) {
Expand Down Expand Up @@ -64,6 +64,17 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "menuBarVisibleCheckBox"
"text": "menu bar visible"
"selected": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuBarVisibleChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "resizableCheckBox"
"text": "resizable"
Expand All @@ -73,7 +84,7 @@ new FormModel {
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "resizableChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
"value": "cell 0 3"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "maximizedBoundsCheckBox"
Expand All @@ -83,7 +94,7 @@ new FormModel {
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "maximizedBoundsChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
"value": "cell 1 3"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "undecoratedCheckBox"
Expand All @@ -93,19 +104,19 @@ new FormModel {
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "undecoratedChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
"value": "cell 0 4"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "Style:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
"value": "cell 0 5"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "Icon:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4"
"value": "cell 1 5"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[fill]"
Expand Down Expand Up @@ -214,7 +225,7 @@ new FormModel {
"value": "cell 0 8"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
"value": "cell 0 6"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[fill]"
Expand Down Expand Up @@ -257,18 +268,18 @@ new FormModel {
"value": "cell 0 2"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
"value": "cell 1 6"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "openDialogButton"
"text": "Open Dialog"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "openDialog", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
"value": "cell 0 7"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 550, 380 )
"size": new java.awt.Dimension( 550, 440 )
} )
add( new FormContainer( "javax.swing.JMenuBar", new FormLayoutManager( class javax.swing.JMenuBar ) ) {
name: "menuBar"
Expand Down Expand Up @@ -434,18 +445,18 @@ new FormModel {
} )
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 410 )
"location": new java.awt.Point( 0, 470 )
"size": new java.awt.Dimension( 255, 30 )
} )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "styleButtonGroup"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 450 )
"location": new java.awt.Point( 0, 520 )
} )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "iconButtonGroup"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 502 )
"location": new java.awt.Point( 0, 570 )
} )
}
}

0 comments on commit 4b7ef6e

Please sign in to comment.