String result = JOptionPane.showInputDialog(this, temp);
Run Code Online (Sandbox Code Playgroud)
result 值将是输入的值.
String result = JOptionPane.showInternalInputDialog(this, temp);
Run Code Online (Sandbox Code Playgroud)
result 即使您输入了一个字符串,该值也将为null.
temp是一个将包含在JOptionPane中的面板.此JOptionPane将显示在另一个自定义JOptioPane之上.
代码1:
public static JFrame frame = null;
public myClass(JFrame frame1)
{
initComponents();
frame = frame1;
String result = JOptionPane.showInternalInputDialog(
frame.getContentPane(), "Sample");
}
Run Code Online (Sandbox Code Playgroud)
代码2:
public static JFrame frame = null;
public myClass(JFrame frame1)
{
initComponents();
frame = frame1;
sampleMethod();
}
public static void sampleMethod()
{
String result = JOptionPane.showInternalInputDialog(
frame.getContentPane(), "Sample");
}
Run Code Online (Sandbox Code Playgroud)
我希望代码1中的结果,但代码必须看起来像代码2.为什么它们有不同的结果?