Showing posts with label JOptionPane. Show all posts
Showing posts with label JOptionPane. Show all posts
Tuesday, May 29, 2012
How to Make Dialogs (JOptionPane)
"How to Make Dialogs (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)" ( http://bit.ly/KLuBtY )
Monday, April 23, 2012
JOptionPane
From Swing, a JOptionPane is a dialog window.
http://docs.oracle.com/javase/7/docs/api/javax/swing/JOptionPane.html
The showInputDialog function returns a String:
String thisString = JOptionPane.showInputDialog("Please input a value");
If you need to use the return value as an int, you may use the following function:
int returnValue = Integer.parseInt(thisString);
(But if the string contains anything other than numbers !!! Your program will CRASH)
If the user presses the Cancel button, showInputDialog will return null.
The following snippet checks if the return is (not) equal to null:
http://docs.oracle.com/javase/7/docs/api/javax/swing/JOptionPane.html
The showInputDialog function returns a String:
String thisString = JOptionPane.showInputDialog("Please input a value");
If you need to use the return value as an int, you may use the following function:
int returnValue = Integer.parseInt(thisString);
(But if the string contains anything other than numbers !!! Your program will CRASH)
If the user presses the Cancel button, showInputDialog will return null.
The following snippet checks if the return is (not) equal to null:
if ((thisString != null) {
// Statements....
}
Subscribe to:
Posts (Atom)