Java: Display Error When JTextField is left Empty -
i've done coding mid-term exam got going on, i've run 1 snag. mainly, cannot seem code throw error message @ user when leave 1 jtextfield empty. think issue having here i've declared double variables each of jtextfields (with double.parsedouble) , far searching around goes, there no way check empty double value. i've tried unusual workaround declare set of string variables same jtextfields (i.e. have double variables attributed them) , testing stringvariable.equals("") doesn't work either.
i've tried going straight jtextfield - myjtextfield.gettext().equals("") - , doesn't throw error message either.
keep in mind in origin java course of study should simple solution.
my code relevant section below:
// if statement display error message if no name entered // or no value input week's homework // or no jcheckbox isselected // remember check against null string or non-selection of jcheckbox if ( ( name.equals ( "" ) ) || (homework1jtextfield.gettext().equals(""))|| //test against wrong range of values homework grades (tut1 < 0 || tut1 > 10)|| (tut2 < 0 || tut2 > 10)|| (tut3 < 0 || tut3 > 10)|| (tut4 < 0 || tut4 > 10)|| (tut5 < 0 || tut5 > 10)|| (tut6 < 0 || tut6 > 10)|| (tut7 < 0 || tut7 > 10)|| (!discussionboardzerojcheckbox.isselected() && !discussionboardonetwojcheckbox.isselected() && !discussionboardthreefourjcheckbox.isselected() && !discussionboardfivesixjcheckbox.isselected() && !discussionboardsevenjcheckbox.isselected() ) ) { // display error message joptionpane.showmessagedialog( null, "full name, homework points , @ to the lowest degree 1 give-and-take board checkbox required information!", "missing information", joptionpane.error_message ); }
i why don't assign intermediate boolean variables each of groups of comparisons. utilize these booleans in if.
print out values of booleans since you're if pretty complex, there's scope lots of things go wrong here.
java
No comments:
Post a Comment