Added ButtonType.borderLess for buttons that look like toolbar buttons but have a focus indicator.

This behavior can be achieved with JideButton, but it would be preferable to use FlatButton instead.
This commit is contained in:
Ingo Kegel
2021-03-22 16:45:37 +01:00
parent 9612a81f2e
commit ae8323e2f8
6 changed files with 49 additions and 6 deletions

View File

@@ -253,6 +253,7 @@ public class FlatComponentsTest
JButton button16 = new JButton();
JButton button24 = new JButton();
JButton button20 = new JButton();
JButton button25 = new JButton();
JLabel toggleButtonLabel = new JLabel();
JToggleButton toggleButton1 = new JToggleButton();
FlatToggleButton toggleButton9 = new FlatToggleButton();
@@ -268,6 +269,7 @@ public class FlatComponentsTest
JToggleButton toggleButton14 = new JToggleButton();
JToggleButton toggleButton21 = new JToggleButton();
JToggleButton toggleButton18 = new JToggleButton();
JToggleButton toggleButton22 = new JToggleButton();
JLabel checkBoxLabel = new JLabel();
JCheckBox checkBox1 = new JCheckBox();
JCheckBox checkBox2 = new JCheckBox();
@@ -578,6 +580,11 @@ public class FlatComponentsTest
button20.setBorder(BorderFactory.createEmptyBorder());
add(button20, "cell 5 1 2 1");
//---- button25 ----
button25.setIcon(UIManager.getIcon("Tree.closedIcon"));
button25.putClientProperty("JButton.buttonType", "borderLess");
add(button25, "cell 5 1 2 1");
//---- toggleButtonLabel ----
toggleButtonLabel.setText("JToggleButton:");
add(toggleButtonLabel, "cell 0 2");
@@ -655,6 +662,12 @@ public class FlatComponentsTest
toggleButton18.setBorder(BorderFactory.createEmptyBorder());
add(toggleButton18, "cell 5 2 2 1");
//---- toggleButton22 ----
toggleButton22.setIcon(UIManager.getIcon("Tree.closedIcon"));
toggleButton22.setSelected(true);
toggleButton22.putClientProperty("JButton.buttonType", "borderLess");
add(toggleButton22, "cell 5 2 2 1");
//---- checkBoxLabel ----
checkBoxLabel.setText("JCheckBox");
add(checkBoxLabel, "cell 0 3");

View File

@@ -156,6 +156,13 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 1 2 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button25"
"icon": &SwingIcon0 new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
"$client.JButton.buttonType": "borderLess"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 1 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "toggleButtonLabel"
"text": "JToggleButton:"
@@ -263,6 +270,14 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 2 2 1"
} )
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "toggleButton22"
"icon": &SwingIcon0 new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
"selected": true
"$client.JButton.buttonType": "borderLess"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 2 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "checkBoxLabel"
"text": "JCheckBox"