I have a JOptionPane.confirmDialog
which contains JTextField
areas inside of a JPanel
. I have also some constraints which prevent invalid input of data by the user. As it is now, there is an alert message which informs the user of a possible field wrong input. But the previous confirmation dialog disappears after pressing ok. I want it to stay on, and possibly highlight the wrongly inputted JTextField
.
How can I do this?
Code:
JPanel myPanel = new JPanel();
myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.Y_AXIS));
myPanel.add(new JLabel("Customer name (Name Surname):"));
myPanel.add(cname);
result = JOptionPane.showConfirmDialog(null, myPanel, "Please Enter Contract Fields", JOptionPane.OK_CANCEL_OPTION);