在JTextField上添加约束 [英] Adding constraint on JTextField
本文介绍了在JTextField上添加约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作一个GUI,其中我使用许多JTextfield
实例来输入用户的输入.我要指定此特定(例如:用户名)文本字段为必填字段.我该怎么办?
I am making a GUI, in which I am using a number of JTextfield
instances to enter the input from the user. I want to specify that this particular (for example : user name) text field is mandatory to fill. How can I do this?
JLabel label_2 = new JLabel("User Name");
label_2.setBounds(23, 167, 126, 21);
panel_1.add(label_2);
textField_2 = new JTextField();
textField_2.setColumns(10);
textField_2.setBounds(178, 129, 210, 20);
panel_1.add(textField_2);
推荐答案
您也可以使用JFormattedTextField
http://docs.oracle.com/javase/7 /docs/api/javax/swing/JFormattedTextField.html
这篇关于在JTextField上添加约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文