Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Prevent editing of a JSpinner's text box  RSS feed

 
Nicholas van Orton
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

Just wondering how to go about preventing text input into a JSpinner's text box (similar to using the setEditable(false) method on a JTextField)?

Thanks
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSpinner spinner = new JSpinner(new SpinnerNumberModel(0, 0, 100, 5)); ((JSpinner.DefaultEditor)spinner.getEditor()).getTextField().setEditable(false);
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!