How to check manual edits on a JSpinner field using DefaultEditor approach

后端 未结 4 2195
孤城傲影
孤城傲影 2021-01-24 06:07

I am adapting code from here:

Value Change Listener to JTextField

EDIT 2

The following code gives me an infinite loop of dialogs when I press the up spin

4条回答
  •  长发绾君心
    2021-01-24 06:32

    The Exception says that the String you pass to Integer.parseInt(..) is an empty string. So make sure to check ((JSpinner.DefaultEditor)spin2.getEditor()).getTextField().getText() for null and empty before passing it to Integer.parseInt(..)

    You may have a look at apache commons-io and the StringUtils class, they have quite a few good methods to ease the pain on checking for empty/blank strings

提交回复
热议问题