java - Multiple input in JOptionPane.showInputDialog -


is there way create multiple input in joptionpane.showinputdialog instead of 1 input?

yes. know can put object object parameter of joptionpane.showxxx methods, , object happens jpanel.

in situation, perhaps use jpanel has several jtextfields in it:

import javax.swing.*;  public class joptionpanemultiinput {    public static void main(string[] args) {       jtextfield xfield = new jtextfield(5);       jtextfield yfield = new jtextfield(5);        jpanel mypanel = new jpanel();       mypanel.add(new jlabel("x:"));       mypanel.add(xfield);       mypanel.add(box.createhorizontalstrut(15)); // spacer       mypanel.add(new jlabel("y:"));       mypanel.add(yfield);        int result = joptionpane.showconfirmdialog(null, mypanel,                 "please enter x , y values", joptionpane.ok_cancel_option);       if (result == joptionpane.ok_option) {          system.out.println("x value: " + xfield.gettext());          system.out.println("y value: " + yfield.gettext());       }    } } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -