you can design a panel your, and add this panel into the inputdialog.for exmaple, JPanel panel = new JPanel(); JOptionPane.showConfirmDialog(thisPanel,panel,"Reference & Related File Editor",JOptionPane.OK_CANCEL_OPTION,JOptionPane.PLAIN_MESSAGE);
JTextField tf1 = new JTextField(10); JTextField tf2 = new JTextField(10); JPanel p = new JPanel(new GridLayout(0, 1, 0, 5)); p.add(new JLabel("请输入数值:", JLabel.LEFT)); p.add(tf1); p.add(tf2);int r = JOptionPane.showConfirmDialog(null, p, "Input", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (r == JOptionPane.OK_OPTION) { String value1 = tf1.getText(); String value2 = tf2.getText(); System.out.println(value1 + " " + value2); } else { System.exit(0); }
JPanel panel = new JPanel();
JOptionPane.showConfirmDialog(thisPanel,panel,"Reference & Related File Editor",JOptionPane.OK_CANCEL_OPTION,JOptionPane.PLAIN_MESSAGE);
JTextField tf2 = new JTextField(10);
JPanel p = new JPanel(new GridLayout(0, 1, 0, 5));
p.add(new JLabel("请输入数值:", JLabel.LEFT));
p.add(tf1);
p.add(tf2);int r = JOptionPane.showConfirmDialog(null, p, "Input",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (r == JOptionPane.OK_OPTION) {
String value1 = tf1.getText();
String value2 = tf2.getText();
System.out.println(value1 + " " + value2);
}
else {
System.exit(0);
}