Java中JTextfield的表单验证? [英] Form validation for JTextfield in Java?

查看:377
本文介绍了Java中JTextfield的表单验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法验证 Java中的一组 JTextFields 。我目前正在使用 sqlite manager neatbeans IDE 来创建一个简单的表单来收集信息以将作业添加到数据库中。我意识到JTextFields太多了。如何通过sqllite抛出可以自定义的异常错误,或者通过属性对话框在Neatbeans中验证每个JTextField。验证是存在检查,即已输入值。自定义验证消息?

Is there an easy way to validate a group of JTextFields in Java. I am currently using sqlite manager, neatbeans IDE to create a simple form that collects information to add a job into the database. I realise there is too many JTextFields. How can I validate each JTextFields either through sqllite throwing an exception error which can be customised, or maybe in Neatbeans through properties dialogue box. Validation is to be presence check, i.e. has a value been entered. Custom validation message?

推荐答案

使用 InputVerifier ,如 如何使用焦点子系统:验证输入 。在此处 >其他人。

Use an InputVerifier, as shown in How to Use the Focus Subsystem : Validating Input. There's a related example here, among others.

这篇关于Java中JTextfield的表单验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆