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

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -