Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

showInputDialog JOptionpane

// The below code reads two ints and displays their min to the user. 
import javax.swing.JOptionPane;

public class JOptionPaneDemo {
	public static void main(String[] args) {
		String num1Str, num2Str;
		int num1, num2;
		int min;

		num1Str = JOptionPane.showInputDialog("Please enter an int value: ");
		num2Str = JOptionPane.showInputDialog("Please enter an int value: ");
		num1 = Integer.parseInt(num1Str);
		num2 = Integer.parseInt(num2Str);
		min = Math.min(num1, num2);
		JOptionPane.showMessageDialog(null, "Min: " + min);
	}
}
 
PREVIOUS NEXT
Tagged: #showInputDialog #JOptionpane
ADD COMMENT
Topic
Name
2+4 =