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);
you can also use JFormattedTextField
http://docs.oracle.com/javase/7/docs/api/javax/swing/JFormattedTextField.html