问题
I'm currently having a problem in netbeans where my JSpinner is allowing you to type in the textfield while I only want the arrows to be used. Is there a way to disable the input of text via properties or some other way?
Thanks
回答1:
Disable the JSpinner's JTextField's using the following:
((JSpinner.DefaultEditor) yourSpinner.getEditor()).getTextField().setEditable(false);
回答2:
You can try it like this
JSpinner.DefaultEditor editor = ( JSpinner.DefaultEditor ) component.getEditor();
editor.getTextField().setEnabled( true );
editor.getTextField().setEditable( false );
来源:https://stackoverflow.com/questions/29105382/how-can-i-disable-the-textfield-area-of-jspinner