Multiple input in JOptionPane.showInputDialog
Несколько строк ввода в диалоге JOptionPane:
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class game {
public static void main(String[] args) {
JTextField podar_kol = new JTextField("5");
JTextField podar_time = new JTextField("70");
JTextField update_time = new JTextField("2000");
Object[] message = {
"Введите количество подарков:", podar_kol,
"Скорость падения подарков:", podar_time,
"Скорость добавления подарков:", update_time
};
/*String s;
s = JOptionPane.showInputDialog(null,
"Введите сложность игры", "вопрос", 3);
*/
int option = JOptionPane.showConfirmDialog(
null, message, "Данные",
JOptionPane.OK_CANCEL_OPTION);
if (option == JOptionPane.OK_OPTION) {
okno win;
int kol = Integer.parseInt(podar_kol.getText());
int t = Integer.parseInt(podar_time.getText());
int speed = Integer.parseInt(update_time.getText());
if(kol >= 1 && kol <= 10)
win = new okno(kol, t, speed);
}
}
}