Professional Documents
Culture Documents
Using JOptionPane
Using JOptionPane
We will be using the JOptionPane methods for input and output. You must import this class so include:
import javax.swing.JOptionPane;
or
import javax.swing.*;
Input: We will use the JOptionPane.showInputDialog to get input from the user. The line that generated the below dialog was:
The information is received as a String. If you wish to convert that information to an integer or a double you need to add:
Output: We will use the JOptionPane.showMessageDialog to output information to the user. The line that generated the below dialog was: