mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 22:47:13 -06:00
Spinner: fixed NullPointerException in case that arrow buttons were removed to create button-less spinner (issue #181)
This commit is contained in:
@@ -186,6 +186,8 @@ public class FlatComponentsTest
|
||||
JLabel spinnerLabel = new JLabel();
|
||||
JSpinner spinner1 = new JSpinner();
|
||||
JSpinner spinner2 = new JSpinner();
|
||||
FlatComponentsTest.ButtonlessSpinner buttonlessSpinner1 = new FlatComponentsTest.ButtonlessSpinner();
|
||||
FlatComponentsTest.ButtonlessSpinner buttonlessSpinner2 = new FlatComponentsTest.ButtonlessSpinner();
|
||||
JComboBox<String> comboBox7 = new JComboBox<>();
|
||||
JSpinner spinner3 = new JSpinner();
|
||||
JLabel textFieldLabel = new JLabel();
|
||||
@@ -678,6 +680,8 @@ public class FlatComponentsTest
|
||||
//---- spinner2 ----
|
||||
spinner2.setEnabled(false);
|
||||
add(spinner2, "cell 2 6,growx");
|
||||
add(buttonlessSpinner1, "cell 3 6,growx");
|
||||
add(buttonlessSpinner2, "cell 4 6,growx");
|
||||
|
||||
//---- comboBox7 ----
|
||||
comboBox7.setEditable(true);
|
||||
@@ -1427,4 +1431,22 @@ public class FlatComponentsTest
|
||||
setBorder( null );
|
||||
}
|
||||
}
|
||||
|
||||
//---- class ButtonlessSpinner --------------------------------------------
|
||||
|
||||
private static class ButtonlessSpinner
|
||||
extends JSpinner
|
||||
{
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
|
||||
// remove arrow buttons
|
||||
for( Component c : getComponents() ) {
|
||||
String name = c.getName();
|
||||
if( "Spinner.nextButton".equals( name ) || "Spinner.previousButton".equals( name ) )
|
||||
remove( c );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "14" encoding: "UTF-8"
|
||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "15" encoding: "UTF-8"
|
||||
|
||||
new FormModel {
|
||||
contentType: "form/swing"
|
||||
@@ -456,6 +456,16 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 6,growx"
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentsTest$ButtonlessSpinner" ) {
|
||||
name: "buttonlessSpinner1"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 3 6,growx"
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentsTest$ButtonlessSpinner" ) {
|
||||
name: "buttonlessSpinner2"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 4 6,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JComboBox" ) {
|
||||
name: "comboBox7"
|
||||
"editable": true
|
||||
|
||||
Reference in New Issue
Block a user