• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

How to handle cancel option in JOptionPane

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I click cancel on this below option it throws alot of errors how to handle this???
Thanks Lisa

//prompt for server and port number.
serverPort = (String)JOptionPane.showInputDialog(flightTable, "Enter the server and port number of the network database. \n I.E. Server:Port");
serverPort = serverPort.trim();
if (serverPort.equals("") | | serverPort.equals(null)) // user has not entered a server
JOptionPane.showMessageDialog(flightTable,"You have not enter a server and/or port.","Server Error", JOptionPane.ERROR_MESSAGE);
else{ //user entered a server
.
.
.
.
.
 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
seats = JOptionPane.showInputDialog(frame, "Please enter number of tickets :");
// Do nothing if user clicks on Cancel button.
if ( seats == null ) return;
// Handle if user enters 0 or space and clicks OK
if(seats.equals("") | | seats.trim().length()==0 | | Integer.valueOf(seats).intValue()==0) {
JOptionPane.showMessageDialog(null, "Please enter valid number.", "Invaid Entry", JOptionPane.INFORMATION_MESSAGE );
return;
}
Hope this helps.
 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks it works fine
Lisa
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic