Joptionpane input dialog cancel option

Joptionpane input dialog cancel option

By: asuroedin Date: 04.06.2017
joptionpane input dialog cancel option

Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum! Post Reply Bookmark Topic Watch Topic New Topic.

joptionpane input dialog cancel option

How to use canceled button in JOptionPane. Hi, I am using JOptionPane to get an int value for a switch statement, but i can't figure out how i can see if someone clicks the "cancel" option.

I looked in the API for it but i still can't figure it out! Doing a quick web search, it appears that clicking "Cancel" causes the input dialog to return null instead of a String. You'll have to get the string returned by the dialog and test it for null to do what you want.

SWING JOptionPane Class

It might be a good idea anyway, just in case the user types "two", so you can control the error message he gets and try again.

ParseInt" if i were just using JOptionPane and looking for a string then it is simple to see if the input is null. Or do i need to write an extra method just to use the cancel button?

How to use canceled button in JOptionPane (Beginning Java forum at Coderanch)

Hi again, OK i got it fixed ; thanks for the tipp Ralph it got me thinking in the right direction! Here is how i fixed it for a reference for anyone else having this problem. What about one of the other kinds of dialog for JOptionPane?

OK cancel option dialog : JOptionPane Dialog « Swing « Java Tutorial

JOptionPane and the default focus. Problems with "while " loops. GMT-6 in summer, GMT-7 in winter.

joptionpane input dialog cancel option
Rating 4,5 stars - 942 reviews
inserted by FC2 system