mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 22:40:53 +03:00
Window decorations: added client property to mark components in embedded menu bar as "caption" (issue #569)
This commit is contained in:
@@ -262,6 +262,16 @@ debug*/
|
||||
menuBar.revalidate();
|
||||
}
|
||||
|
||||
private void addCaption() {
|
||||
JLabel caption = new JLabel( "Caption" );
|
||||
caption.setBackground( Color.green );
|
||||
caption.setOpaque( true );
|
||||
caption.putClientProperty( FlatClientProperties.COMPONENT_TITLE_BAR_CAPTION, true );
|
||||
|
||||
menuBar.add( caption );
|
||||
menuBar.revalidate();
|
||||
}
|
||||
|
||||
private void removeMenu() {
|
||||
int menuCount = menuBar.getMenuCount();
|
||||
if( menuCount <= 0 )
|
||||
@@ -445,6 +455,7 @@ debug*/
|
||||
JPanel panel3 = new JPanel();
|
||||
addMenuButton = new JButton();
|
||||
addGlueButton = new JButton();
|
||||
addCaptionButton = new JButton();
|
||||
removeMenuButton = new JButton();
|
||||
changeMenuButton = new JButton();
|
||||
changeTitleButton = new JButton();
|
||||
@@ -547,6 +558,7 @@ debug*/
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]unrel" +
|
||||
"[]"));
|
||||
|
||||
@@ -560,20 +572,25 @@ debug*/
|
||||
addGlueButton.addActionListener(e -> addGlue());
|
||||
panel3.add(addGlueButton, "cell 0 1");
|
||||
|
||||
//---- addCaptionButton ----
|
||||
addCaptionButton.setText("Add caption");
|
||||
addCaptionButton.addActionListener(e -> addCaption());
|
||||
panel3.add(addCaptionButton, "cell 0 2");
|
||||
|
||||
//---- removeMenuButton ----
|
||||
removeMenuButton.setText("Remove menu");
|
||||
removeMenuButton.addActionListener(e -> removeMenu());
|
||||
panel3.add(removeMenuButton, "cell 0 2");
|
||||
panel3.add(removeMenuButton, "cell 0 3");
|
||||
|
||||
//---- changeMenuButton ----
|
||||
changeMenuButton.setText("Change menu");
|
||||
changeMenuButton.addActionListener(e -> changeMenu());
|
||||
panel3.add(changeMenuButton, "cell 0 3");
|
||||
panel3.add(changeMenuButton, "cell 0 4");
|
||||
|
||||
//---- changeTitleButton ----
|
||||
changeTitleButton.setText("Change title");
|
||||
changeTitleButton.addActionListener(e -> changeTitle());
|
||||
panel3.add(changeTitleButton, "cell 0 4");
|
||||
panel3.add(changeTitleButton, "cell 0 5");
|
||||
}
|
||||
add(panel3, "cell 2 0 1 8,aligny top,growy 0");
|
||||
|
||||
@@ -961,6 +978,7 @@ debug*/
|
||||
private JCheckBox rightCompCheckBox;
|
||||
private JButton addMenuButton;
|
||||
private JButton addGlueButton;
|
||||
private JButton addCaptionButton;
|
||||
private JButton removeMenuButton;
|
||||
private JButton changeMenuButton;
|
||||
private JButton changeTitleButton;
|
||||
|
||||
@@ -36,7 +36,7 @@ new FormModel {
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "hidemode 3"
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[][][][]unrel[]"
|
||||
"$rowConstraints": "[][][][][]unrel[]"
|
||||
} ) {
|
||||
name: "panel3"
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
@@ -59,6 +59,16 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "addCaptionButton"
|
||||
"text": "Add caption"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "addCaption", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "removeMenuButton"
|
||||
"text": "Remove menu"
|
||||
@@ -67,7 +77,7 @@ new FormModel {
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "removeMenu", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 2"
|
||||
"value": "cell 0 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "changeMenuButton"
|
||||
@@ -77,7 +87,7 @@ new FormModel {
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "changeMenu", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3"
|
||||
"value": "cell 0 4"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "changeTitleButton"
|
||||
@@ -87,7 +97,7 @@ new FormModel {
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "changeTitle", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 4"
|
||||
"value": "cell 0 5"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 0 1 8,aligny top,growy 0"
|
||||
|
||||
Reference in New Issue
Block a user