mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 22:40:53 +03:00
Window decorations: support embedding menu bar into title pane (enabled by default) (issues #47 and #82)
This commit is contained in:
@@ -23,6 +23,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.swing.*;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
import net.miginfocom.swing.*;
|
||||
|
||||
/**
|
||||
@@ -103,6 +104,12 @@ public class FlatWindowDecorationsTest
|
||||
}
|
||||
}
|
||||
|
||||
private void menuBarEmbeddedChanged() {
|
||||
JRootPane rootPane = getWindowRootPane();
|
||||
if( rootPane != null )
|
||||
rootPane.putClientProperty( FlatClientProperties.MENU_BAR_EMBEDDED, menuBarEmbeddedCheckBox.isSelected() );
|
||||
}
|
||||
|
||||
private void resizableChanged() {
|
||||
Window window = SwingUtilities.windowForComponent( this );
|
||||
if( window instanceof Frame )
|
||||
@@ -178,6 +185,7 @@ public class FlatWindowDecorationsTest
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
menuBarCheckBox = new JCheckBox();
|
||||
menuBarEmbeddedCheckBox = new JCheckBox();
|
||||
resizableCheckBox = new JCheckBox();
|
||||
JLabel label1 = new JLabel();
|
||||
JLabel label2 = new JLabel();
|
||||
@@ -231,6 +239,7 @@ public class FlatWindowDecorationsTest
|
||||
"[fill]",
|
||||
// rows
|
||||
"para[]0" +
|
||||
"[]0" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[top]" +
|
||||
@@ -242,19 +251,25 @@ public class FlatWindowDecorationsTest
|
||||
menuBarCheckBox.addActionListener(e -> menuBarChanged());
|
||||
add(menuBarCheckBox, "cell 0 0");
|
||||
|
||||
//---- menuBarEmbeddedCheckBox ----
|
||||
menuBarEmbeddedCheckBox.setText("embedded menu bar");
|
||||
menuBarEmbeddedCheckBox.setSelected(true);
|
||||
menuBarEmbeddedCheckBox.addActionListener(e -> menuBarEmbeddedChanged());
|
||||
add(menuBarEmbeddedCheckBox, "cell 0 1");
|
||||
|
||||
//---- resizableCheckBox ----
|
||||
resizableCheckBox.setText("resizable");
|
||||
resizableCheckBox.setSelected(true);
|
||||
resizableCheckBox.addActionListener(e -> resizableChanged());
|
||||
add(resizableCheckBox, "cell 0 1");
|
||||
add(resizableCheckBox, "cell 0 2");
|
||||
|
||||
//---- label1 ----
|
||||
label1.setText("Style:");
|
||||
add(label1, "cell 0 2");
|
||||
add(label1, "cell 0 3");
|
||||
|
||||
//---- label2 ----
|
||||
label2.setText("Icon:");
|
||||
add(label2, "cell 1 2");
|
||||
add(label2, "cell 1 3");
|
||||
|
||||
//======== panel1 ========
|
||||
{
|
||||
@@ -319,7 +334,7 @@ public class FlatWindowDecorationsTest
|
||||
styleFileChooserRadioButton.addActionListener(e -> decorationStyleChanged());
|
||||
panel1.add(styleFileChooserRadioButton, "cell 0 8");
|
||||
}
|
||||
add(panel1, "cell 0 3");
|
||||
add(panel1, "cell 0 4");
|
||||
|
||||
//======== panel2 ========
|
||||
{
|
||||
@@ -348,12 +363,12 @@ public class FlatWindowDecorationsTest
|
||||
iconTestRandomRadioButton.addActionListener(e -> iconChanged());
|
||||
panel2.add(iconTestRandomRadioButton, "cell 0 2");
|
||||
}
|
||||
add(panel2, "cell 1 3");
|
||||
add(panel2, "cell 1 4");
|
||||
|
||||
//---- openDialogButton ----
|
||||
openDialogButton.setText("Open Dialog");
|
||||
openDialogButton.addActionListener(e -> openDialog());
|
||||
add(openDialogButton, "cell 0 4");
|
||||
add(openDialogButton, "cell 0 5");
|
||||
|
||||
//======== menuBar ========
|
||||
{
|
||||
@@ -545,6 +560,7 @@ public class FlatWindowDecorationsTest
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||
private JCheckBox menuBarCheckBox;
|
||||
private JCheckBox menuBarEmbeddedCheckBox;
|
||||
private JCheckBox resizableCheckBox;
|
||||
private JRadioButton styleNoneRadioButton;
|
||||
private JRadioButton styleFrameRadioButton;
|
||||
|
||||
@@ -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[fill]"
|
||||
"$rowConstraints": "para[]0[][][top][]"
|
||||
"$rowConstraints": "para[]0[]0[][][top][]"
|
||||
} ) {
|
||||
name: "this"
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
@@ -23,6 +23,17 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "menuBarEmbeddedCheckBox"
|
||||
"text": "embedded menu bar"
|
||||
"selected": true
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuBarEmbeddedChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "resizableCheckBox"
|
||||
"text": "resizable"
|
||||
@@ -32,19 +43,19 @@ new FormModel {
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "resizableChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 1"
|
||||
"value": "cell 0 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label1"
|
||||
"text": "Style:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 2"
|
||||
"value": "cell 0 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label2"
|
||||
"text": "Icon:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
"value": "cell 1 3"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
@@ -153,7 +164,7 @@ new FormModel {
|
||||
"value": "cell 0 8"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3"
|
||||
"value": "cell 0 4"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
@@ -196,14 +207,14 @@ new FormModel {
|
||||
"value": "cell 0 2"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 3"
|
||||
"value": "cell 1 4"
|
||||
} )
|
||||
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 4"
|
||||
"value": "cell 0 5"
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
|
||||
@@ -1038,6 +1038,32 @@ TextPane.selectionForeground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
||||
TextPaneUI com.formdev.flatlaf.ui.FlatTextPaneUI
|
||||
|
||||
|
||||
#---- TitlePane ----
|
||||
|
||||
TitlePane.background #303234 javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.buttonHoverBackground #484c4f com.formdev.flatlaf.util.DerivedColor [UI] lighten(10% autoInverse)
|
||||
TitlePane.buttonMaximizedHeight 22
|
||||
TitlePane.buttonPressedBackground #616569 com.formdev.flatlaf.util.DerivedColor [UI] lighten(20% autoInverse)
|
||||
TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI]
|
||||
TitlePane.closeHoverBackground #e81123 javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.closeHoverForeground #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.closeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI]
|
||||
TitlePane.closePressedBackground #99e81123 javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.closePressedForeground #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.embeddedForeground #959595 javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.foreground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.iconMargins 3,8,3,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||
TitlePane.iconSize 16,16 javax.swing.plaf.DimensionUIResource [UI]
|
||||
TitlePane.iconifyIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI]
|
||||
TitlePane.inactiveBackground #303234 javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.inactiveForeground #777777 javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.maximizeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
|
||||
TitlePane.menuBarEmbedded true
|
||||
TitlePane.menuBarMargins 0,8,0,22 javax.swing.plaf.InsetsUIResource [UI]
|
||||
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
|
||||
TitlePane.titleMargins 3,8,3,8 javax.swing.plaf.InsetsUIResource [UI]
|
||||
|
||||
|
||||
#---- TitledBorder ----
|
||||
|
||||
TitledBorder.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatLineBorder [UI] lineColor=#515151 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000
|
||||
|
||||
@@ -1040,6 +1040,32 @@ TextPane.selectionForeground #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||
TextPaneUI com.formdev.flatlaf.ui.FlatTextPaneUI
|
||||
|
||||
|
||||
#---- TitlePane ----
|
||||
|
||||
TitlePane.background #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.buttonHoverBackground #e6e6e6 com.formdev.flatlaf.util.DerivedColor [UI] darken(10% autoInverse)
|
||||
TitlePane.buttonMaximizedHeight 22
|
||||
TitlePane.buttonPressedBackground #cccccc com.formdev.flatlaf.util.DerivedColor [UI] darken(20% autoInverse)
|
||||
TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI]
|
||||
TitlePane.closeHoverBackground #e81123 javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.closeHoverForeground #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.closeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI]
|
||||
TitlePane.closePressedBackground #99e81123 javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.closePressedForeground #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.embeddedForeground #595959 javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.foreground #000000 javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.iconMargins 3,8,3,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||
TitlePane.iconSize 16,16 javax.swing.plaf.DimensionUIResource [UI]
|
||||
TitlePane.iconifyIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI]
|
||||
TitlePane.inactiveBackground #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.inactiveForeground #8c8c8c javax.swing.plaf.ColorUIResource [UI]
|
||||
TitlePane.maximizeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
|
||||
TitlePane.menuBarEmbedded true
|
||||
TitlePane.menuBarMargins 0,8,0,22 javax.swing.plaf.InsetsUIResource [UI]
|
||||
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
|
||||
TitlePane.titleMargins 3,8,3,8 javax.swing.plaf.InsetsUIResource [UI]
|
||||
|
||||
|
||||
#---- TitledBorder ----
|
||||
|
||||
TitledBorder.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatLineBorder [UI] lineColor=#d1d1d1 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000
|
||||
|
||||
Reference in New Issue
Block a user