Reputation: 81
So I have made a GUI application where I have 3 TextFields and 1 JDateChooser. During runtime I want to check whether or not the user has typed anything into the Components. If they haven't typed anything I want to show an error message.
The Code I've tried :-
if (!cardnumb1.equals("") || !pin1.equals("") || !call1.equals("") || !fname1.equals(""))
{
verify1.setVisible(true);
}
if (cardnumb2.equals("") || pin2.equals("") || cal12.equals("") || fname2.equals(""))
{
JOptionPane.showMessageDialog(this,"error");
}
Where cardnumb1,pin1,fname1 are textFields and call1 is JDateChooser
The cal12.equals("")
throws a .equals() on incomparable String types
My declaration of Datatype for call1 is
Date call1 = date1.getDate();
Upvotes: 0
Views: 81