java - Converting User Input to Integer with Custom Error Message -


i working on program accepts user input through joptionpane window. goal create if statement validates user input integer. i've tried integer.parseint method throws exception, cannot display own joptionpane window informing user of mistake. i'm new programming , cannot think of way convert string integer (or @ least way works) use in if statement. ideas?

thanks!

if integer somehow after joptionpane message displayed, may want take @ code continuously prompts user enter valid integer:

int number = 0; boolean ok = false; string input = "";  while(!ok) {     try     {         number = integer.parseint( input );         ok = true;     }     catch(exception e)     {         // change joptionpane message here warn user.     } } 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -