java - NumberFormatException error while checking if JTextField is empty -
i getting numberformatexception
error during runtime. error caused when checking if jtextfield
empty using if statement.
private void btnaddnumbermouseclicked(java.awt.event.mouseevent evt) { numberarray.add(integer.parseint(txtnumber.gettext())); if(!(txtnumber.gettext().equals(""))){ scoreslist.settext(""); (int = 0; < numberarray.size(); i++) { scoreslist.append(integer.tostring(numberarray.get(i)) + "\n"); } } txtnumber.settext("");
might want change this:
integer.tostring()
to this
string.valueof()
or append integer in textarea without casting string.
also try use .isempty() method instead of .equals()
Comments
Post a Comment