• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JOptionPane errors with 0 length input

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using JOptionPane.showInputDialog(" asdfsfasdf " );
I get a system error when I simply press the OK button without
entering any data.
Can you please suggest a way to avoid this while still staying
within the confines of JOP?
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is really a Swing question, so I've moved it to the Swing/AWT forum for you.
 
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Don.
I have tried using
String text = JOptionPane.showInputDialog(" asdfsfasdf " );
and have no problem pressing the OK button without entering any data. I am using JDK1.2.2 on an NT4.0 system.
Perhaps you are trying to do something with text (which is an empty String if you click OK without entering any data) and this is causing the error? Can you post that part of your code?
Stephanie
 
Don Smathers
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stephanie, you are absolutely correct !!
I adjusted code as follows:
aNbr = JOptionPane.showInputDialog( "What is acct nbr " );
if (aNbr.length() == 0) System.exit(0);
acctNbr = Integer.parseInt( aNbr );//this was failing
and it works just fine --- Many thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic