mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
Button and ToggleButton: Threat Unicode surrogate character pair as single character and make button square (issue #234)
This commit is contained in:
@@ -19,6 +19,8 @@ FlatLaf Change Log
|
|||||||
|
|
||||||
#### Fixed bugs
|
#### Fixed bugs
|
||||||
|
|
||||||
|
- Button and ToggleButton: Threat Unicode surrogate character pair as single
|
||||||
|
character and make button square. (issue #234)
|
||||||
- Extras: Added missing export of package
|
- Extras: Added missing export of package
|
||||||
`com.formdev.flatlaf.extras.components` to Java 9 module descriptor.
|
`com.formdev.flatlaf.extras.components` to Java 9 module descriptor.
|
||||||
- JIDE Common Layer: Invoke `LookAndFeelFactory.installJideExtension()` when
|
- JIDE Common Layer: Invoke `LookAndFeelFactory.installJideExtension()` when
|
||||||
|
|||||||
@@ -251,7 +251,10 @@ public class FlatButtonUI
|
|||||||
Icon icon = ((AbstractButton)c).getIcon();
|
Icon icon = ((AbstractButton)c).getIcon();
|
||||||
String text = ((AbstractButton)c).getText();
|
String text = ((AbstractButton)c).getText();
|
||||||
return (icon != null && (text == null || text.isEmpty())) ||
|
return (icon != null && (text == null || text.isEmpty())) ||
|
||||||
(icon == null && text != null && ("...".equals( text ) || text.length() == 1));
|
(icon == null && text != null &&
|
||||||
|
("...".equals( text ) ||
|
||||||
|
text.length() == 1 ||
|
||||||
|
(text.length() == 2 && Character.isSurrogatePair( text.charAt( 0 ), text.charAt( 1 ) ))));
|
||||||
}
|
}
|
||||||
|
|
||||||
static final int TYPE_OTHER = -1;
|
static final int TYPE_OTHER = -1;
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ public class FlatComponentsTest
|
|||||||
JButton button14 = new JButton();
|
JButton button14 = new JButton();
|
||||||
JButton button15 = new JButton();
|
JButton button15 = new JButton();
|
||||||
JButton button16 = new JButton();
|
JButton button16 = new JButton();
|
||||||
|
JButton button24 = new JButton();
|
||||||
JButton button20 = new JButton();
|
JButton button20 = new JButton();
|
||||||
JLabel toggleButtonLabel = new JLabel();
|
JLabel toggleButtonLabel = new JLabel();
|
||||||
JToggleButton toggleButton1 = new JToggleButton();
|
JToggleButton toggleButton1 = new JToggleButton();
|
||||||
@@ -262,6 +263,7 @@ public class FlatComponentsTest
|
|||||||
JToggleButton toggleButton12 = new JToggleButton();
|
JToggleButton toggleButton12 = new JToggleButton();
|
||||||
JToggleButton toggleButton13 = new JToggleButton();
|
JToggleButton toggleButton13 = new JToggleButton();
|
||||||
JToggleButton toggleButton14 = new JToggleButton();
|
JToggleButton toggleButton14 = new JToggleButton();
|
||||||
|
JToggleButton toggleButton21 = new JToggleButton();
|
||||||
JToggleButton toggleButton18 = new JToggleButton();
|
JToggleButton toggleButton18 = new JToggleButton();
|
||||||
JLabel checkBoxLabel = new JLabel();
|
JLabel checkBoxLabel = new JLabel();
|
||||||
JCheckBox checkBox1 = new JCheckBox();
|
JCheckBox checkBox1 = new JCheckBox();
|
||||||
@@ -549,24 +551,28 @@ public class FlatComponentsTest
|
|||||||
|
|
||||||
//---- button13 ----
|
//---- button13 ----
|
||||||
button13.setIcon(UIManager.getIcon("Tree.closedIcon"));
|
button13.setIcon(UIManager.getIcon("Tree.closedIcon"));
|
||||||
add(button13, "cell 5 1");
|
add(button13, "cell 5 1 2 1");
|
||||||
|
|
||||||
//---- button14 ----
|
//---- button14 ----
|
||||||
button14.setText("...");
|
button14.setText("...");
|
||||||
add(button14, "cell 5 1");
|
add(button14, "cell 5 1 2 1");
|
||||||
|
|
||||||
//---- button15 ----
|
//---- button15 ----
|
||||||
button15.setText("\u2026");
|
button15.setText("\u2026");
|
||||||
add(button15, "cell 5 1");
|
add(button15, "cell 5 1 2 1");
|
||||||
|
|
||||||
//---- button16 ----
|
//---- button16 ----
|
||||||
button16.setText("#");
|
button16.setText("#");
|
||||||
add(button16, "cell 5 1");
|
add(button16, "cell 5 1 2 1");
|
||||||
|
|
||||||
|
//---- button24 ----
|
||||||
|
button24.setText("A");
|
||||||
|
add(button24, "cell 5 1 2 1");
|
||||||
|
|
||||||
//---- button20 ----
|
//---- button20 ----
|
||||||
button20.setText("Empty border");
|
button20.setText("Empty border");
|
||||||
button20.setBorder(BorderFactory.createEmptyBorder());
|
button20.setBorder(BorderFactory.createEmptyBorder());
|
||||||
add(button20, "cell 6 1");
|
add(button20, "cell 5 1 2 1");
|
||||||
|
|
||||||
//---- toggleButtonLabel ----
|
//---- toggleButtonLabel ----
|
||||||
toggleButtonLabel.setText("JToggleButton:");
|
toggleButtonLabel.setText("JToggleButton:");
|
||||||
@@ -618,27 +624,32 @@ public class FlatComponentsTest
|
|||||||
//---- toggleButton11 ----
|
//---- toggleButton11 ----
|
||||||
toggleButton11.setIcon(UIManager.getIcon("Tree.closedIcon"));
|
toggleButton11.setIcon(UIManager.getIcon("Tree.closedIcon"));
|
||||||
toggleButton11.setSelected(true);
|
toggleButton11.setSelected(true);
|
||||||
add(toggleButton11, "cell 5 2");
|
add(toggleButton11, "cell 5 2 2 1");
|
||||||
|
|
||||||
//---- toggleButton12 ----
|
//---- toggleButton12 ----
|
||||||
toggleButton12.setText("...");
|
toggleButton12.setText("...");
|
||||||
toggleButton12.setSelected(true);
|
toggleButton12.setSelected(true);
|
||||||
add(toggleButton12, "cell 5 2");
|
add(toggleButton12, "cell 5 2 2 1");
|
||||||
|
|
||||||
//---- toggleButton13 ----
|
//---- toggleButton13 ----
|
||||||
toggleButton13.setText("\u2026");
|
toggleButton13.setText("\u2026");
|
||||||
toggleButton13.setSelected(true);
|
toggleButton13.setSelected(true);
|
||||||
add(toggleButton13, "cell 5 2");
|
add(toggleButton13, "cell 5 2 2 1");
|
||||||
|
|
||||||
//---- toggleButton14 ----
|
//---- toggleButton14 ----
|
||||||
toggleButton14.setText("#");
|
toggleButton14.setText("#");
|
||||||
toggleButton14.setSelected(true);
|
toggleButton14.setSelected(true);
|
||||||
add(toggleButton14, "cell 5 2");
|
add(toggleButton14, "cell 5 2 2 1");
|
||||||
|
|
||||||
|
//---- toggleButton21 ----
|
||||||
|
toggleButton21.setText("A");
|
||||||
|
toggleButton21.setSelected(true);
|
||||||
|
add(toggleButton21, "cell 5 2 2 1");
|
||||||
|
|
||||||
//---- toggleButton18 ----
|
//---- toggleButton18 ----
|
||||||
toggleButton18.setText("Empty border");
|
toggleButton18.setText("Empty border");
|
||||||
toggleButton18.setBorder(BorderFactory.createEmptyBorder());
|
toggleButton18.setBorder(BorderFactory.createEmptyBorder());
|
||||||
add(toggleButton18, "cell 6 2");
|
add(toggleButton18, "cell 5 2 2 1");
|
||||||
|
|
||||||
//---- checkBoxLabel ----
|
//---- checkBoxLabel ----
|
||||||
checkBoxLabel.setText("JCheckBox");
|
checkBoxLabel.setText("JCheckBox");
|
||||||
@@ -1579,6 +1590,11 @@ public class FlatComponentsTest
|
|||||||
buttonGroup1.add(magentaCyanOutlineRadioButton);
|
buttonGroup1.add(magentaCyanOutlineRadioButton);
|
||||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||||
|
|
||||||
|
// Unicode surrogate character pair "script capital A"
|
||||||
|
// https://www.compart.com/en/unicode/U+1D49C
|
||||||
|
button24.setText("\uD835\uDC9C");
|
||||||
|
toggleButton21.setText("\uD835\uDC9C");
|
||||||
|
|
||||||
// BasicComboBoxRenderer customRenderer = new BasicComboBoxRenderer();
|
// BasicComboBoxRenderer customRenderer = new BasicComboBoxRenderer();
|
||||||
// customRenderer.setBorder( new LineBorder( Color.red ) );
|
// customRenderer.setBorder( new LineBorder( Color.red ) );
|
||||||
// comboBox1.setRenderer( customRenderer );
|
// comboBox1.setRenderer( customRenderer );
|
||||||
|
|||||||
@@ -123,32 +123,38 @@ new FormModel {
|
|||||||
name: "button13"
|
name: "button13"
|
||||||
"icon": &SwingIcon0 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 ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 1"
|
"value": "cell 5 1 2 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JButton" ) {
|
add( new FormComponent( "javax.swing.JButton" ) {
|
||||||
name: "button14"
|
name: "button14"
|
||||||
"text": "..."
|
"text": "..."
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 1"
|
"value": "cell 5 1 2 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JButton" ) {
|
add( new FormComponent( "javax.swing.JButton" ) {
|
||||||
name: "button15"
|
name: "button15"
|
||||||
"text": "…"
|
"text": "…"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 1"
|
"value": "cell 5 1 2 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JButton" ) {
|
add( new FormComponent( "javax.swing.JButton" ) {
|
||||||
name: "button16"
|
name: "button16"
|
||||||
"text": "#"
|
"text": "#"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 1"
|
"value": "cell 5 1 2 1"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JButton" ) {
|
||||||
|
name: "button24"
|
||||||
|
"text": "A"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 5 1 2 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JButton" ) {
|
add( new FormComponent( "javax.swing.JButton" ) {
|
||||||
name: "button20"
|
name: "button20"
|
||||||
"text": "Empty border"
|
"text": "Empty border"
|
||||||
"border": &EmptyBorder0 new javax.swing.border.EmptyBorder( 0, 0, 0, 0 )
|
"border": &EmptyBorder0 new javax.swing.border.EmptyBorder( 0, 0, 0, 0 )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 6 1"
|
"value": "cell 5 1 2 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "toggleButtonLabel"
|
name: "toggleButtonLabel"
|
||||||
@@ -220,35 +226,42 @@ new FormModel {
|
|||||||
"icon": #SwingIcon0
|
"icon": #SwingIcon0
|
||||||
"selected": true
|
"selected": true
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 2"
|
"value": "cell 5 2 2 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||||
name: "toggleButton12"
|
name: "toggleButton12"
|
||||||
"text": "..."
|
"text": "..."
|
||||||
"selected": true
|
"selected": true
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 2"
|
"value": "cell 5 2 2 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||||
name: "toggleButton13"
|
name: "toggleButton13"
|
||||||
"text": "…"
|
"text": "…"
|
||||||
"selected": true
|
"selected": true
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 2"
|
"value": "cell 5 2 2 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||||
name: "toggleButton14"
|
name: "toggleButton14"
|
||||||
"text": "#"
|
"text": "#"
|
||||||
"selected": true
|
"selected": true
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 2"
|
"value": "cell 5 2 2 1"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||||
|
name: "toggleButton21"
|
||||||
|
"text": "A"
|
||||||
|
"selected": true
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 5 2 2 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||||
name: "toggleButton18"
|
name: "toggleButton18"
|
||||||
"text": "Empty border"
|
"text": "Empty border"
|
||||||
"border": #EmptyBorder0
|
"border": #EmptyBorder0
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 6 2"
|
"value": "cell 5 2 2 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "checkBoxLabel"
|
name: "checkBoxLabel"
|
||||||
|
|||||||
Reference in New Issue
Block a user