import javax.swing.JOptionPane;
class ShowInput
{
public static void main(String args[])
{
String s=(String)JOptionPane.showInputDialog(null,
"Choose one", "Input",
JOptionPane.INFORMATION_MESSAGE, null,
"1,2,3", "2"); int n=Integer.parseInt(s);
int nn=n*n;
JOptionPane.showMessageDialog(
null,
s+"的平方为"+nn,
"标题:平方",
JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
class ShowInput
{
public static void main(String args[])
{
String s=(String)JOptionPane.showInputDialog(null,
"Choose one", "Input",
JOptionPane.INFORMATION_MESSAGE, null,
"1,2,3", "2"); int n=Integer.parseInt(s);
int nn=n*n;
JOptionPane.showMessageDialog(
null,
s+"的平方为"+nn,
"标题:平方",
JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
import javax.swing.JOptionPane;
class ShowInput
{
public static void main(String args[])
{
String s=(String)JOptionPane.showInputDialog(null,
"Choose one", "Input",
JOptionPane.INFORMATION_MESSAGE, null,
new Object[] {"1","2","3"}, "2"); int n=Integer.parseInt(s);
int nn=n*n;
JOptionPane.showMessageDialog(
null,
s+"的平方为"+nn,
"标题:平方",
JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
提示用户在可以指定初始选择、可能选择及其他所有选项的模块化的对话框中输入内容。