mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 15:07:11 -06:00
ToggleButton: make toggle button square if it has an icon but no text or text is "..." or a single character
This commit is contained in:
@@ -87,13 +87,17 @@ public class FlatComponentsTest
|
||||
JToggleButton toggleButton10 = new JToggleButton();
|
||||
JToggleButton toggleButton3 = new JToggleButton();
|
||||
JToggleButton toggleButton4 = new JToggleButton();
|
||||
JToggleButton toggleButton5 = new JToggleButton();
|
||||
JToggleButton toggleButton8 = new JToggleButton();
|
||||
JToggleButton toggleButton11 = new JToggleButton();
|
||||
JToggleButton toggleButton12 = new JToggleButton();
|
||||
JToggleButton toggleButton13 = new JToggleButton();
|
||||
JToggleButton toggleButton14 = new JToggleButton();
|
||||
JLabel checkBoxLabel = new JLabel();
|
||||
JCheckBox checkBox1 = new JCheckBox();
|
||||
JCheckBox checkBox2 = new JCheckBox();
|
||||
JCheckBox checkBox3 = new JCheckBox();
|
||||
JCheckBox checkBox4 = new JCheckBox();
|
||||
JToggleButton toggleButton5 = new JToggleButton();
|
||||
JToggleButton toggleButton8 = new JToggleButton();
|
||||
JLabel radioButtonLabel = new JLabel();
|
||||
JRadioButton radioButton1 = new JRadioButton();
|
||||
JRadioButton radioButton2 = new JRadioButton();
|
||||
@@ -203,6 +207,9 @@ public class FlatComponentsTest
|
||||
JButton button7 = new JButton();
|
||||
JButton button8 = new JButton();
|
||||
JToggleButton toggleButton6 = new JToggleButton();
|
||||
JToggleButton toggleButton15 = new JToggleButton();
|
||||
JToggleButton toggleButton16 = new JToggleButton();
|
||||
JToggleButton toggleButton17 = new JToggleButton();
|
||||
|
||||
//======== this ========
|
||||
setLayout(new MigLayout(
|
||||
@@ -353,18 +360,25 @@ public class FlatComponentsTest
|
||||
toggleButton4.setSelected(true);
|
||||
add(toggleButton4, "cell 4 2");
|
||||
|
||||
//---- toggleButton5 ----
|
||||
toggleButton5.setText("tab");
|
||||
toggleButton5.putClientProperty("JButton.buttonType", "tab");
|
||||
toggleButton5.setSelected(true);
|
||||
add(toggleButton5, "cell 5 2");
|
||||
//---- toggleButton11 ----
|
||||
toggleButton11.setIcon(UIManager.getIcon("Tree.closedIcon"));
|
||||
toggleButton11.setSelected(true);
|
||||
add(toggleButton11, "cell 5 2");
|
||||
|
||||
//---- toggleButton8 ----
|
||||
toggleButton8.setText("tab");
|
||||
toggleButton8.putClientProperty("JButton.buttonType", "tab");
|
||||
toggleButton8.setEnabled(false);
|
||||
toggleButton8.setSelected(true);
|
||||
add(toggleButton8, "cell 5 2");
|
||||
//---- toggleButton12 ----
|
||||
toggleButton12.setText("...");
|
||||
toggleButton12.setSelected(true);
|
||||
add(toggleButton12, "cell 5 2");
|
||||
|
||||
//---- toggleButton13 ----
|
||||
toggleButton13.setText("\u2026");
|
||||
toggleButton13.setSelected(true);
|
||||
add(toggleButton13, "cell 5 2");
|
||||
|
||||
//---- toggleButton14 ----
|
||||
toggleButton14.setText("#");
|
||||
toggleButton14.setSelected(true);
|
||||
add(toggleButton14, "cell 5 2");
|
||||
|
||||
//---- checkBoxLabel ----
|
||||
checkBoxLabel.setText("JCheckBox");
|
||||
@@ -392,6 +406,19 @@ public class FlatComponentsTest
|
||||
checkBox4.setEnabled(false);
|
||||
add(checkBox4, "cell 4 3");
|
||||
|
||||
//---- toggleButton5 ----
|
||||
toggleButton5.setText("tab");
|
||||
toggleButton5.putClientProperty("JButton.buttonType", "tab");
|
||||
toggleButton5.setSelected(true);
|
||||
add(toggleButton5, "cell 5 3");
|
||||
|
||||
//---- toggleButton8 ----
|
||||
toggleButton8.setText("tab");
|
||||
toggleButton8.putClientProperty("JButton.buttonType", "tab");
|
||||
toggleButton8.setEnabled(false);
|
||||
toggleButton8.setSelected(true);
|
||||
add(toggleButton8, "cell 5 3");
|
||||
|
||||
//---- radioButtonLabel ----
|
||||
radioButtonLabel.setText("JRadioButton:");
|
||||
add(radioButtonLabel, "cell 0 4");
|
||||
@@ -979,6 +1006,21 @@ public class FlatComponentsTest
|
||||
toggleButton6.setIcon(UIManager.getIcon("Tree.leafIcon"));
|
||||
toggleButton6.setSelected(true);
|
||||
toolBar1.add(toggleButton6);
|
||||
|
||||
//---- toggleButton15 ----
|
||||
toggleButton15.setIcon(UIManager.getIcon("FileView.computerIcon"));
|
||||
toggleButton15.setSelected(true);
|
||||
toolBar1.add(toggleButton15);
|
||||
|
||||
//---- toggleButton16 ----
|
||||
toggleButton16.setIcon(UIManager.getIcon("FileView.floppyDriveIcon"));
|
||||
toggleButton16.setSelected(true);
|
||||
toolBar1.add(toggleButton16);
|
||||
|
||||
//---- toggleButton17 ----
|
||||
toggleButton17.setIcon(UIManager.getIcon("FileView.hardDriveIcon"));
|
||||
toggleButton17.setSelected(true);
|
||||
toolBar1.add(toggleButton17);
|
||||
}
|
||||
add(toolBar1, "cell 1 23 3 1,growx");
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||
|
||||
@@ -98,7 +98,7 @@ new FormModel {
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "button13"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
|
||||
"icon": &SwingIcon0 new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 1"
|
||||
} )
|
||||
@@ -170,18 +170,29 @@ new FormModel {
|
||||
"value": "cell 4 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton5"
|
||||
"text": "tab"
|
||||
"$client.JButton.buttonType": "tab"
|
||||
name: "toggleButton11"
|
||||
"icon": #SwingIcon0
|
||||
"selected": true
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton8"
|
||||
"text": "tab"
|
||||
"$client.JButton.buttonType": "tab"
|
||||
"enabled": false
|
||||
name: "toggleButton12"
|
||||
"text": "..."
|
||||
"selected": true
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton13"
|
||||
"text": "…"
|
||||
"selected": true
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton14"
|
||||
"text": "#"
|
||||
"selected": true
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 2"
|
||||
@@ -222,6 +233,23 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 4 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton5"
|
||||
"text": "tab"
|
||||
"$client.JButton.buttonType": "tab"
|
||||
"selected": true
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton8"
|
||||
"text": "tab"
|
||||
"$client.JButton.buttonType": "tab"
|
||||
"enabled": false
|
||||
"selected": true
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "radioButtonLabel"
|
||||
"text": "JRadioButton:"
|
||||
@@ -784,18 +812,18 @@ new FormModel {
|
||||
"orientation": 1
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "button9"
|
||||
"icon": &SwingIcon0 new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
|
||||
"icon": &SwingIcon1 new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "button10"
|
||||
"icon": &SwingIcon1 new com.jformdesigner.model.SwingIcon( 2, "Tree.openIcon" )
|
||||
"icon": &SwingIcon2 new com.jformdesigner.model.SwingIcon( 2, "Tree.openIcon" )
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToolBar$Separator" ) {
|
||||
name: "separator5"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "button11"
|
||||
"icon": &SwingIcon2 new com.jformdesigner.model.SwingIcon( 2, "Tree.leafIcon" )
|
||||
"icon": &SwingIcon3 new com.jformdesigner.model.SwingIcon( 2, "Tree.leafIcon" )
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton7"
|
||||
@@ -963,18 +991,18 @@ new FormModel {
|
||||
name: "toolBar1"
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "button4"
|
||||
"icon": #SwingIcon0
|
||||
"icon": #SwingIcon1
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "button6"
|
||||
"icon": #SwingIcon1
|
||||
"icon": #SwingIcon2
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToolBar$Separator" ) {
|
||||
name: "separator3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "button7"
|
||||
"icon": #SwingIcon2
|
||||
"icon": #SwingIcon3
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToolBar$Separator" ) {
|
||||
name: "separator4"
|
||||
@@ -990,6 +1018,21 @@ new FormModel {
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.leafIcon" )
|
||||
"selected": true
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton15"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.computerIcon" )
|
||||
"selected": true
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton16"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.floppyDriveIcon" )
|
||||
"selected": true
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton17"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.hardDriveIcon" )
|
||||
"selected": true
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 23 3 1,growx"
|
||||
} )
|
||||
|
||||
Reference in New Issue
Block a user