mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 15:07:11 -06:00
ComboBox: no longer ignore JComboBox.prototypeDisplayValue when computing popup width (issue #80)
This commit is contained in:
@@ -6,6 +6,8 @@ FlatLaf Change Log
|
|||||||
- Linux: Fixed scaling if `GDK_SCALE` environment variable is set or if running
|
- Linux: Fixed scaling if `GDK_SCALE` environment variable is set or if running
|
||||||
on JetBrains Runtime. (issue #69)
|
on JetBrains Runtime. (issue #69)
|
||||||
- Tree: Fixed repainting wide selection on focus gained/lost.
|
- Tree: Fixed repainting wide selection on focus gained/lost.
|
||||||
|
- ComboBox: No longer ignore `JComboBox.prototypeDisplayValue` when computing
|
||||||
|
popup width. (issue #80)
|
||||||
- Support changing default font used for all components with automatic scaling
|
- Support changing default font used for all components with automatic scaling
|
||||||
UI if using larger font. Use `UIManager.put( "defaultFont", myFont );`
|
UI if using larger font. Use `UIManager.put( "defaultFont", myFont );`
|
||||||
- No longer use system property `sun.java2d.uiScale`. (Java 8 only)
|
- No longer use system property `sun.java2d.uiScale`. (Java 8 only)
|
||||||
|
|||||||
@@ -480,13 +480,8 @@ public class FlatComboBoxUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Rectangle computePopupBounds( int px, int py, int pw, int ph ) {
|
protected Rectangle computePopupBounds( int px, int py, int pw, int ph ) {
|
||||||
// get maximum display size of all items, ignoring prototype value
|
// get maximum display size of all items
|
||||||
Object prototype = comboBox.getPrototypeDisplayValue();
|
|
||||||
if( prototype != null )
|
|
||||||
comboBox.setPrototypeDisplayValue( null );
|
|
||||||
Dimension displaySize = getDisplaySize();
|
Dimension displaySize = getDisplaySize();
|
||||||
if( prototype != null )
|
|
||||||
comboBox.setPrototypeDisplayValue( prototype );
|
|
||||||
|
|
||||||
// make popup wider if necessary
|
// make popup wider if necessary
|
||||||
if( displaySize.width > pw ) {
|
if( displaySize.width > pw ) {
|
||||||
|
|||||||
@@ -310,14 +310,13 @@ class BasicComponentsPanel
|
|||||||
add(comboBox4, "cell 4 4,growx");
|
add(comboBox4, "cell 4 4,growx");
|
||||||
|
|
||||||
//---- comboBox5 ----
|
//---- comboBox5 ----
|
||||||
comboBox5.setPrototypeDisplayValue("12345");
|
|
||||||
comboBox5.setModel(new DefaultComboBoxModel<>(new String[] {
|
comboBox5.setModel(new DefaultComboBoxModel<>(new String[] {
|
||||||
"wide popup if text is longer",
|
"wide popup if text is longer",
|
||||||
"aa",
|
"aa",
|
||||||
"bbb",
|
"bbb",
|
||||||
"cccc"
|
"cccc"
|
||||||
}));
|
}));
|
||||||
add(comboBox5, "cell 5 4,growx");
|
add(comboBox5, "cell 5 4,growx,wmax 100");
|
||||||
|
|
||||||
//---- spinnerLabel ----
|
//---- spinnerLabel ----
|
||||||
spinnerLabel.setText("JSpinner:");
|
spinnerLabel.setText("JSpinner:");
|
||||||
|
|||||||
@@ -242,7 +242,6 @@ new FormModel {
|
|||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JComboBox" ) {
|
add( new FormComponent( "javax.swing.JComboBox" ) {
|
||||||
name: "comboBox5"
|
name: "comboBox5"
|
||||||
"prototypeDisplayValue": "12345"
|
|
||||||
"model": new javax.swing.DefaultComboBoxModel {
|
"model": new javax.swing.DefaultComboBoxModel {
|
||||||
selectedItem: "wide popup if text is longer"
|
selectedItem: "wide popup if text is longer"
|
||||||
addElement( "wide popup if text is longer" )
|
addElement( "wide popup if text is longer" )
|
||||||
@@ -251,7 +250,7 @@ new FormModel {
|
|||||||
addElement( "cccc" )
|
addElement( "cccc" )
|
||||||
}
|
}
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 4,growx"
|
"value": "cell 5 4,growx,wmax 100"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "spinnerLabel"
|
name: "spinnerLabel"
|
||||||
|
|||||||
@@ -513,14 +513,13 @@ public class FlatComponentsTest
|
|||||||
add(comboBox4, "cell 4 5,growx");
|
add(comboBox4, "cell 4 5,growx");
|
||||||
|
|
||||||
//---- comboBox5 ----
|
//---- comboBox5 ----
|
||||||
comboBox5.setPrototypeDisplayValue("12345");
|
|
||||||
comboBox5.setModel(new DefaultComboBoxModel<>(new String[] {
|
comboBox5.setModel(new DefaultComboBoxModel<>(new String[] {
|
||||||
"wide popup if text is longer",
|
"wide popup if text is longer",
|
||||||
"aa",
|
"aa",
|
||||||
"bbb",
|
"bbb",
|
||||||
"cccc"
|
"cccc"
|
||||||
}));
|
}));
|
||||||
add(comboBox5, "cell 5 5,growx");
|
add(comboBox5, "cell 5 5,growx,wmax 100");
|
||||||
|
|
||||||
//---- spinnerLabel ----
|
//---- spinnerLabel ----
|
||||||
spinnerLabel.setText("JSpinner:");
|
spinnerLabel.setText("JSpinner:");
|
||||||
|
|||||||
@@ -373,7 +373,6 @@ new FormModel {
|
|||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JComboBox" ) {
|
add( new FormComponent( "javax.swing.JComboBox" ) {
|
||||||
name: "comboBox5"
|
name: "comboBox5"
|
||||||
"prototypeDisplayValue": "12345"
|
|
||||||
"model": new javax.swing.DefaultComboBoxModel {
|
"model": new javax.swing.DefaultComboBoxModel {
|
||||||
selectedItem: "wide popup if text is longer"
|
selectedItem: "wide popup if text is longer"
|
||||||
addElement( "wide popup if text is longer" )
|
addElement( "wide popup if text is longer" )
|
||||||
@@ -382,7 +381,7 @@ new FormModel {
|
|||||||
addElement( "cccc" )
|
addElement( "cccc" )
|
||||||
}
|
}
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 5,growx"
|
"value": "cell 5 5,growx,wmax 100"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "spinnerLabel"
|
name: "spinnerLabel"
|
||||||
|
|||||||
Reference in New Issue
Block a user