Extras: FlatTriStateCheckBox reworked

This commit is contained in:
Karl Tauber
2020-12-19 16:00:57 +01:00
parent ef065d31a0
commit a7c6a881b3
5 changed files with 220 additions and 72 deletions

View File

@@ -359,7 +359,7 @@ public class FlatContainerTest
}
private void secondTabClosableChanged() {
Boolean closable = secondTabClosableCheckBox.getValue();
Boolean closable = secondTabClosableCheckBox.getChecked();
for( FlatTabbedPane tabbedPane : allTabbedPanes ) {
if( tabbedPane.getTabCount() > 1 ) {

View File

@@ -38,8 +38,8 @@ public class FlatExtrasTest
public FlatExtrasTest() {
initComponents();
triStateLabel1.setText( triStateCheckBox1.getState().toString() );
triStateLabel2.setText( triStateCheckBox2.getState().toString() );
triStateCheckBox1Changed();
triStateCheckBox2Changed();
addSVGIcon( "actions/copy.svg" );
addSVGIcon( "actions/colors.svg" );
@@ -90,6 +90,10 @@ public class FlatExtrasTest
triStateLabel2.setText( triStateCheckBox2.getState().toString() );
}
private void triStateCheckBox3Changed() {
triStateLabel3.setText( triStateCheckBox3.getState().toString() );
}
private void disabledChanged() {
boolean enabled = !disabledCheckBox.isSelected();
@@ -120,6 +124,8 @@ public class FlatExtrasTest
label1 = new JLabel();
triStateCheckBox1 = new FlatTriStateCheckBox();
triStateLabel1 = new JLabel();
triStateCheckBox3 = new FlatTriStateCheckBox();
triStateLabel3 = new JLabel();
triStateCheckBox2 = new FlatTriStateCheckBox();
triStateLabel2 = new JLabel();
label2 = new JLabel();
@@ -166,20 +172,31 @@ public class FlatExtrasTest
triStateLabel1.setEnabled(false);
add(triStateLabel1, "cell 2 0,gapx 30");
//---- triStateCheckBox3 ----
triStateCheckBox3.setText("alt state cycle order");
triStateCheckBox3.setAltStateCycleOrder(true);
triStateCheckBox3.addActionListener(e -> triStateCheckBox3Changed());
add(triStateCheckBox3, "cell 1 1");
//---- triStateLabel3 ----
triStateLabel3.setText("text");
triStateLabel3.setEnabled(false);
add(triStateLabel3, "cell 2 1,gapx 30");
//---- triStateCheckBox2 ----
triStateCheckBox2.setText("third state disabled");
triStateCheckBox2.setThirdStateEnabled(false);
triStateCheckBox2.setAllowIndeterminate(false);
triStateCheckBox2.addActionListener(e -> triStateCheckBox2Changed());
add(triStateCheckBox2, "cell 1 1");
add(triStateCheckBox2, "cell 1 2");
//---- triStateLabel2 ----
triStateLabel2.setText("text");
triStateLabel2.setEnabled(false);
add(triStateLabel2, "cell 2 1,gapx 30");
add(triStateLabel2, "cell 2 2,gapx 30");
//---- label2 ----
label2.setText("SVG Icons:");
add(label2, "cell 0 2");
add(label2, "cell 0 3");
//======== svgIconsPanel ========
{
@@ -190,50 +207,50 @@ public class FlatExtrasTest
// rows
"[grow,center]"));
}
add(svgIconsPanel, "cell 1 2 2 1");
add(svgIconsPanel, "cell 1 3 2 1");
//---- label3 ----
label3.setText("The icons may change colors when switching to another theme.");
add(label3, "cell 1 3 2 1");
add(label3, "cell 1 4 2 1");
//---- label4 ----
label4.setText("Disabled SVG Icons:");
add(label4, "cell 0 4");
add(label4, "cell 0 5");
//---- disabledLabel ----
disabledLabel.setText("label");
add(disabledLabel, "cell 1 4 2 1");
add(disabledLabel, "cell 1 5 2 1");
//---- disabledButton ----
disabledButton.setText("button");
add(disabledButton, "cell 1 4 2 1");
add(disabledTabbedPane, "cell 1 4 2 1");
add(disabledButton, "cell 1 5 2 1");
add(disabledTabbedPane, "cell 1 5 2 1");
//---- label5 ----
label5.setText("only setIcon()");
label5.setEnabled(false);
add(label5, "cell 1 4 2 1,gapx 20");
add(label5, "cell 1 5 2 1,gapx 20");
//---- disabledCheckBox ----
disabledCheckBox.setText("disabled");
disabledCheckBox.setSelected(true);
disabledCheckBox.setMnemonic('D');
disabledCheckBox.addActionListener(e -> disabledChanged());
add(disabledCheckBox, "cell 0 5,alignx left,growx 0");
add(disabledCheckBox, "cell 0 6,alignx left,growx 0");
//---- disabledLabel2 ----
disabledLabel2.setText("label");
add(disabledLabel2, "cell 1 5 2 1");
add(disabledLabel2, "cell 1 6 2 1");
//---- disabledButton2 ----
disabledButton2.setText("button");
add(disabledButton2, "cell 1 5 2 1");
add(disabledTabbedPane2, "cell 1 5 2 1");
add(disabledButton2, "cell 1 6 2 1");
add(disabledTabbedPane2, "cell 1 6 2 1");
//---- label6 ----
label6.setText("setIcon() and setDisabledIcon()");
label6.setEnabled(false);
add(label6, "cell 1 5 2 1,gapx 20");
add(label6, "cell 1 6 2 1,gapx 20");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
@@ -241,6 +258,8 @@ public class FlatExtrasTest
private JLabel label1;
private FlatTriStateCheckBox triStateCheckBox1;
private JLabel triStateLabel1;
private FlatTriStateCheckBox triStateCheckBox3;
private JLabel triStateLabel3;
private FlatTriStateCheckBox triStateCheckBox2;
private JLabel triStateLabel2;
private JLabel label2;

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.2.0.298" Java: "15" encoding: "UTF-8"
JFDML JFormDesigner: "7.0.3.1.342" Java: "15" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -30,25 +30,40 @@ new FormModel {
"value": "cell 2 0,gapx 30"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "triStateCheckBox2"
"text": "third state disabled"
"thirdStateEnabled": false
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox2Changed", false ) )
name: "triStateCheckBox3"
"text": "alt state cycle order"
"altStateCycleOrder": true
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox3Changed", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "triStateLabel3"
"text": "text"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1,gapx 30"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "triStateCheckBox2"
"text": "third state disabled"
"allowIndeterminate": false
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox2Changed", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "triStateLabel2"
"text": "text"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1,gapx 30"
"value": "cell 2 2,gapx 30"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "SVG Icons:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
"value": "cell 0 3"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3"
@@ -57,43 +72,43 @@ new FormModel {
} ) {
name: "svgIconsPanel"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2 2 1"
"value": "cell 1 3 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"text": "The icons may change colors when switching to another theme."
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3 2 1"
"value": "cell 1 4 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4"
"text": "Disabled SVG Icons:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
"value": "cell 0 5"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "disabledLabel"
"text": "label"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4 2 1"
"value": "cell 1 5 2 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "disabledButton"
"text": "button"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4 2 1"
"value": "cell 1 5 2 1"
} )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "disabledTabbedPane"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4 2 1"
"value": "cell 1 5 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label5"
"text": "only setIcon()"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4 2 1,gapx 20"
"value": "cell 1 5 2 1,gapx 20"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "disabledCheckBox"
@@ -102,35 +117,35 @@ new FormModel {
"mnemonic": 68
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "disabledChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5,alignx left,growx 0"
"value": "cell 0 6,alignx left,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "disabledLabel2"
"text": "label"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5 2 1"
"value": "cell 1 6 2 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "disabledButton2"
"text": "button"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5 2 1"
"value": "cell 1 6 2 1"
} )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "disabledTabbedPane2"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5 2 1"
"value": "cell 1 6 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label6"
"text": "setIcon() and setDisabledIcon()"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5 2 1,gapx 20"
"value": "cell 1 6 2 1,gapx 20"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 595, 300 )
"size": new java.awt.Dimension( 595, 470 )
} )
}
}