Demo: improved layout of tabbed pane options

This commit is contained in:
Karl Tauber
2019-09-15 16:55:27 +02:00
parent 87e20375f0
commit 60d493d4ce
4 changed files with 152 additions and 118 deletions

View File

@@ -94,26 +94,25 @@ public class FlatContainerTest
JLabel label7 = new JLabel(); JLabel label7 = new JLabel();
JPanel panel8 = new JPanel(); JPanel panel8 = new JPanel();
JLabel label8 = new JLabel(); JLabel label8 = new JLabel();
JPanel panel14 = new JPanel();
moreTabsCheckBox = new JCheckBox();
tabScrollCheckBox = new JCheckBox(); tabScrollCheckBox = new JCheckBox();
hasFullBorderCheckBox = new JCheckBox(); hasFullBorderCheckBox = new JCheckBox();
moreTabsCheckBox = new JCheckBox();
CellConstraints cc = new CellConstraints(); CellConstraints cc = new CellConstraints();
//======== this ======== //======== this ========
setLayout(new MigLayout( setLayout(new MigLayout(
"insets 0,hidemode 3", "insets 0,hidemode 3",
// columns // columns
"[grow,fill]" + "[grow,fill]",
"[fill]",
// rows // rows
"[grow,fill]" + "[grow,fill]"));
"[]"));
//======== panel9 ======== //======== panel9 ========
{ {
panel9.setLayout(new FormLayout( panel9.setLayout(new FormLayout(
"70dlu:grow, $lcgap, 70dlu:grow", "70dlu:grow, $lcgap, 70dlu:grow",
"default, $lgap, fill:70dlu, $lgap, pref, 2*($lgap, fill:70dlu:grow), 2*($lgap, pref)")); "default, $lgap, fill:70dlu, $lgap, pref, 2*($lgap, fill:70dlu:grow), $lgap, pref"));
//---- splitPaneLabel ---- //---- splitPaneLabel ----
splitPaneLabel.setText("JSplitPane:"); splitPaneLabel.setText("JSplitPane:");
@@ -280,23 +279,36 @@ public class FlatContainerTest
} }
panel9.add(tabbedPane4, cc.xy(3, 9)); panel9.add(tabbedPane4, cc.xy(3, 9));
//---- tabScrollCheckBox ---- //======== panel14 ========
tabScrollCheckBox.setText("tabLayoutPolicy = SCROLL"); {
tabScrollCheckBox.setMnemonic('S'); panel14.setLayout(new MigLayout(
tabScrollCheckBox.addActionListener(e -> tabScrollChanged()); "insets 0,hidemode 3",
panel9.add(tabScrollCheckBox, cc.xy(1, 11, CellConstraints.LEFT, CellConstraints.DEFAULT)); // columns
"[]" +
"[]" +
"[]",
// rows
"[center]"));
//---- hasFullBorderCheckBox ---- //---- moreTabsCheckBox ----
hasFullBorderCheckBox.setText("JTabbedPane.hasFullBorder"); moreTabsCheckBox.setText("more tabs");
hasFullBorderCheckBox.setMnemonic('F'); moreTabsCheckBox.setMnemonic('M');
hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged()); moreTabsCheckBox.addActionListener(e -> moreTabsChanged());
panel9.add(hasFullBorderCheckBox, cc.xy(3, 11, CellConstraints.LEFT, CellConstraints.DEFAULT)); panel14.add(moreTabsCheckBox, "cell 0 0");
//---- moreTabsCheckBox ---- //---- tabScrollCheckBox ----
moreTabsCheckBox.setText("more tabs"); tabScrollCheckBox.setText("tabLayoutPolicy = SCROLL");
moreTabsCheckBox.setMnemonic('M'); tabScrollCheckBox.setMnemonic('S');
moreTabsCheckBox.addActionListener(e -> moreTabsChanged()); tabScrollCheckBox.addActionListener(e -> tabScrollChanged());
panel9.add(moreTabsCheckBox, cc.xy(1, 13, CellConstraints.LEFT, CellConstraints.DEFAULT)); panel14.add(tabScrollCheckBox, "cell 1 0,alignx left,growx 0");
//---- hasFullBorderCheckBox ----
hasFullBorderCheckBox.setText("JTabbedPane.hasFullBorder");
hasFullBorderCheckBox.setMnemonic('F');
hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged());
panel14.add(hasFullBorderCheckBox, "cell 2 0,alignx left,growx 0");
}
panel9.add(panel14, cc.xywh(1, 11, 3, 1));
} }
add(panel9, "cell 0 0"); add(panel9, "cell 0 0");
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
@@ -307,8 +319,8 @@ public class FlatContainerTest
private JTabbedPane tabbedPane3; private JTabbedPane tabbedPane3;
private JTabbedPane tabbedPane2; private JTabbedPane tabbedPane2;
private JTabbedPane tabbedPane4; private JTabbedPane tabbedPane4;
private JCheckBox moreTabsCheckBox;
private JCheckBox tabScrollCheckBox; private JCheckBox tabScrollCheckBox;
private JCheckBox hasFullBorderCheckBox; private JCheckBox hasFullBorderCheckBox;
private JCheckBox moreTabsCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables // JFormDesigner - End of variables declaration //GEN-END:variables
} }

View File

@@ -8,13 +8,13 @@ new FormModel {
} }
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3" "$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[grow,fill][fill]" "$columnConstraints": "[grow,fill]"
"$rowConstraints": "[grow,fill][]" "$rowConstraints": "[grow,fill]"
} ) { } ) {
name: "this" name: "this"
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class com.jgoodies.forms.layout.FormLayout ) { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class com.jgoodies.forms.layout.FormLayout ) {
"$columnSpecs": "70dlu:grow, labelcompgap, 70dlu:grow" "$columnSpecs": "70dlu:grow, labelcompgap, 70dlu:grow"
"$rowSpecs": "default, linegap, fill:70dlu, linegap, pref, linegap, fill:70dlu:grow, linegap, fill:70dlu:grow, linegap, pref, linegap, pref" "$rowSpecs": "default, linegap, fill:70dlu, linegap, pref, linegap, fill:70dlu:grow, linegap, fill:70dlu:grow, linegap, pref"
} ) { } ) {
name: "panel9" name: "panel9"
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
@@ -197,51 +197,55 @@ new FormModel {
"gridX": 3 "gridX": 3
"gridY": 9 "gridY": 9
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
name: "tabScrollCheckBox" "$layoutConstraints": "insets 0,hidemode 3"
"text": "tabLayoutPolicy = SCROLL" "$columnConstraints": "[][][]"
"mnemonic": 83 "$rowConstraints": "[center]"
auxiliary() { } ) {
"JavaCodeGenerator.variableLocal": false name: "panel14"
} add( new FormComponent( "javax.swing.JCheckBox" ) {
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabScrollChanged", false ) ) name: "moreTabsCheckBox"
"text": "more tabs"
"mnemonic": 77
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "moreTabsChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "tabScrollCheckBox"
"text": "tabLayoutPolicy = SCROLL"
"mnemonic": 83
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabScrollChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0,alignx left,growx 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "hasFullBorderCheckBox"
"text": "JTabbedPane.hasFullBorder"
"mnemonic": 70
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hasFullBorderChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0,alignx left,growx 0"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 1
"gridY": 11 "gridY": 11
"hAlign": sfield com.jgoodies.forms.layout.CellConstraints LEFT "gridWidth": 3
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "hasFullBorderCheckBox"
"text": "JTabbedPane.hasFullBorder"
"mnemonic": 70
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hasFullBorderChanged", false ) )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 3
"gridY": 11
"hAlign": sfield com.jgoodies.forms.layout.CellConstraints LEFT
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "moreTabsCheckBox"
"text": "more tabs"
"mnemonic": 77
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "moreTabsChanged", false ) )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 1
"gridY": 13
"hAlign": sfield com.jgoodies.forms.layout.CellConstraints LEFT
} ) } )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0" "value": "cell 0 0"
} ) } )
}, new FormLayoutConstraints( null ) { }, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 ) "location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 405, 515 ) "size": new java.awt.Dimension( 500, 515 )
} ) } )
} }
} }

View File

@@ -92,9 +92,10 @@ class TabsPanel
JLabel label7 = new JLabel(); JLabel label7 = new JLabel();
JPanel panel8 = new JPanel(); JPanel panel8 = new JPanel();
JLabel label8 = new JLabel(); JLabel label8 = new JLabel();
JPanel panel14 = new JPanel();
moreTabsCheckBox = new JCheckBox();
tabScrollCheckBox = new JCheckBox(); tabScrollCheckBox = new JCheckBox();
hasFullBorderCheckBox = new JCheckBox(); hasFullBorderCheckBox = new JCheckBox();
moreTabsCheckBox = new JCheckBox();
CellConstraints cc = new CellConstraints(); CellConstraints cc = new CellConstraints();
//======== this ======== //======== this ========
@@ -109,7 +110,7 @@ class TabsPanel
{ {
panel9.setLayout(new FormLayout( panel9.setLayout(new FormLayout(
"70dlu:grow, $lcgap, 70dlu:grow", "70dlu:grow, $lcgap, 70dlu:grow",
"default, $lgap, fill:70dlu, $lgap, pref, 2*($lgap, fill:70dlu:grow), 2*($lgap, pref)")); "default, $lgap, fill:70dlu, $lgap, pref, 2*($lgap, fill:70dlu:grow), $lgap, pref"));
//---- splitPaneLabel ---- //---- splitPaneLabel ----
splitPaneLabel.setText("JSplitPane:"); splitPaneLabel.setText("JSplitPane:");
@@ -276,23 +277,36 @@ class TabsPanel
} }
panel9.add(tabbedPane4, cc.xy(3, 9)); panel9.add(tabbedPane4, cc.xy(3, 9));
//---- tabScrollCheckBox ---- //======== panel14 ========
tabScrollCheckBox.setText("tabLayoutPolicy = SCROLL"); {
tabScrollCheckBox.setMnemonic('S'); panel14.setLayout(new MigLayout(
tabScrollCheckBox.addActionListener(e -> tabScrollChanged()); "insets 0,hidemode 3",
panel9.add(tabScrollCheckBox, cc.xy(1, 11, CellConstraints.LEFT, CellConstraints.DEFAULT)); // columns
"[]" +
"[]" +
"[]",
// rows
"[center]"));
//---- hasFullBorderCheckBox ---- //---- moreTabsCheckBox ----
hasFullBorderCheckBox.setText("JTabbedPane.hasFullBorder"); moreTabsCheckBox.setText("more tabs");
hasFullBorderCheckBox.setMnemonic('F'); moreTabsCheckBox.setMnemonic('M');
hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged()); moreTabsCheckBox.addActionListener(e -> moreTabsChanged());
panel9.add(hasFullBorderCheckBox, cc.xy(3, 11, CellConstraints.LEFT, CellConstraints.DEFAULT)); panel14.add(moreTabsCheckBox, "cell 0 0");
//---- moreTabsCheckBox ---- //---- tabScrollCheckBox ----
moreTabsCheckBox.setText("more tabs"); tabScrollCheckBox.setText("tabLayoutPolicy = SCROLL");
moreTabsCheckBox.setMnemonic('M'); tabScrollCheckBox.setMnemonic('S');
moreTabsCheckBox.addActionListener(e -> moreTabsChanged()); tabScrollCheckBox.addActionListener(e -> tabScrollChanged());
panel9.add(moreTabsCheckBox, cc.xy(1, 13, CellConstraints.LEFT, CellConstraints.DEFAULT)); panel14.add(tabScrollCheckBox, "cell 1 0,alignx left,growx 0");
//---- hasFullBorderCheckBox ----
hasFullBorderCheckBox.setText("JTabbedPane.hasFullBorder");
hasFullBorderCheckBox.setMnemonic('F');
hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged());
panel14.add(hasFullBorderCheckBox, "cell 2 0,alignx left,growx 0");
}
panel9.add(panel14, cc.xywh(1, 11, 3, 1));
} }
add(panel9, "cell 0 0"); add(panel9, "cell 0 0");
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
@@ -303,8 +317,8 @@ class TabsPanel
private JTabbedPane tabbedPane3; private JTabbedPane tabbedPane3;
private JTabbedPane tabbedPane2; private JTabbedPane tabbedPane2;
private JTabbedPane tabbedPane4; private JTabbedPane tabbedPane4;
private JCheckBox moreTabsCheckBox;
private JCheckBox tabScrollCheckBox; private JCheckBox tabScrollCheckBox;
private JCheckBox hasFullBorderCheckBox; private JCheckBox hasFullBorderCheckBox;
private JCheckBox moreTabsCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables // JFormDesigner - End of variables declaration //GEN-END:variables
} }

View File

@@ -14,7 +14,7 @@ new FormModel {
name: "this" name: "this"
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class com.jgoodies.forms.layout.FormLayout ) { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class com.jgoodies.forms.layout.FormLayout ) {
"$columnSpecs": "70dlu:grow, labelcompgap, 70dlu:grow" "$columnSpecs": "70dlu:grow, labelcompgap, 70dlu:grow"
"$rowSpecs": "default, linegap, fill:70dlu, linegap, pref, linegap, fill:70dlu:grow, linegap, fill:70dlu:grow, linegap, pref, linegap, pref" "$rowSpecs": "default, linegap, fill:70dlu, linegap, pref, linegap, fill:70dlu:grow, linegap, fill:70dlu:grow, linegap, pref"
} ) { } ) {
name: "panel9" name: "panel9"
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
@@ -197,51 +197,55 @@ new FormModel {
"gridX": 3 "gridX": 3
"gridY": 9 "gridY": 9
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
name: "tabScrollCheckBox" "$layoutConstraints": "insets 0,hidemode 3"
"text": "tabLayoutPolicy = SCROLL" "$columnConstraints": "[][][]"
"mnemonic": 83 "$rowConstraints": "[center]"
auxiliary() { } ) {
"JavaCodeGenerator.variableLocal": false name: "panel14"
} add( new FormComponent( "javax.swing.JCheckBox" ) {
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabScrollChanged", false ) ) name: "moreTabsCheckBox"
"text": "more tabs"
"mnemonic": 77
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "moreTabsChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "tabScrollCheckBox"
"text": "tabLayoutPolicy = SCROLL"
"mnemonic": 83
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabScrollChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0,alignx left,growx 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "hasFullBorderCheckBox"
"text": "JTabbedPane.hasFullBorder"
"mnemonic": 70
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hasFullBorderChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0,alignx left,growx 0"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 1
"gridY": 11 "gridY": 11
"hAlign": sfield com.jgoodies.forms.layout.CellConstraints LEFT "gridWidth": 3
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "hasFullBorderCheckBox"
"text": "JTabbedPane.hasFullBorder"
"mnemonic": 70
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hasFullBorderChanged", false ) )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 3
"gridY": 11
"hAlign": sfield com.jgoodies.forms.layout.CellConstraints LEFT
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "moreTabsCheckBox"
"text": "more tabs"
"mnemonic": 77
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "moreTabsChanged", false ) )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 1
"gridY": 13
"hAlign": sfield com.jgoodies.forms.layout.CellConstraints LEFT
} ) } )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0" "value": "cell 0 0"
} ) } )
}, new FormLayoutConstraints( null ) { }, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 ) "location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 400, 585 ) "size": new java.awt.Dimension( 500, 515 )
} ) } )
} }
} }