Java SWT User Input Validation

↘锁芯ラ 提交于 2019-12-12 15:21:04

问题


What is the Java convention when it comes to user input validation in SWT? I read that there are FieldEditors which are very convenient fields but sadly only for preferences and dialogue boxes.

I also read that there is an IValidator interface. But it is often used with data binding, which is in my case, most of my inputs do not need any data binding yet. Also, IValidator requires me to write my own validation methods even for simple validations such as integer only, letters only, etc.

Since the FieldEditors cannot be applied in normal usage of input fields, what other convenient way can I use to do validation on user inputs? I am using SWT for my Java GUI.

Thanks!


回答1:


You can validate the input of your control in a VerifyListener. See this forum thread for further explanation.

Alternatively, you can check out RCP Toolbox which has a built-in easy-to-use validation framework. See this article.



来源:https://stackoverflow.com/questions/6089893/java-swt-user-input-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!