• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSpinner$ListEditor$ListFormatter cannot be cast to javax.swing.text.DefaultFormatter

 
Tom Landry
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Working with a sample but encountering a casting issue.

It compiles fine but encounters the following error during execution.

Exception in thread "main" java.lang.ClassCastException: javax.swing.JSpinner$ListEditor$ListFormatter cannot be cast to javax.swing.text.DefaultFormatter
at SpinnerEditor.<init>(Main.java:60)
at Main.<init>(Main.java:44)
at Main.main(Main.java:27)

Not sure exactly how to cast this to get past the error.

 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the formatter is not a DefaultFormatter but an instance of a different sub class of AbstractFormatter. Which means you can't use setCommitsOnValidEdit.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!