Java Swing: Implementing a validity check of input values

前端 未结 4 965
猫巷女王i
猫巷女王i 2020-12-31 16:08

In my Swing application, the user must insert numbers and values, before switching to the next window. Now as a clean program should, I check every input if its valid or not

4条回答
  •  情话喂你
    2020-12-31 16:40

    There are many things you can do. A simple one is to have a method that checks a list of strings for parseability into int. For additional checks you'd have more methods that check some typical thing, like number range. So split each kind of check into its own method and compose them as needed.

    Otherwise there are full validation frameworks that handle this sort of thing. They are easiliy googlable, I'd say.

提交回复
热议问题