Results 1 to 3 of 3
  1. #1
    saad is offline Member
    Join Date
    Aug 2016
    Posts
    1
    Rep Power
    0

    Question Multiple UserInput Using JOptionPane.showInputDialog

    Assalam-o-Alaikum!
    I am new to Java. My Teacher gave me a project of making BioData Using JOptionPane.ShowInputDialog......
    I made it completely just like this.......

    import javax.swing.*;
    public class BioData {

    public static void main(String[] args) {
    // TODO code application logic here
    String name,
    fathername,
    cast,
    address,
    phone,
    cnic,
    gender;


    name=JOptionPane.showInputDialog(null,"Name:");
    fathername=JOptionPane.showInputDialog(null,"Fathe r Name:");
    cast=JOptionPane.showInputDialog(null,"Cast:");
    address=JOptionPane.showInputDialog(null,"Address: ");
    phone=JOptionPane.showInputDialog(null,"Phone:");
    cnic=JOptionPane.showInputDialog(null,"Cnic:");
    gender=JOptionPane.showInputDialog(null,"Gender:") ;
    }
    }



    But this code gives one user input at a time but i want all...........
    means....just like it.......

    Name:
    Father Name:
    Address:
    and soo on.
    Thanks in Advance for helping me out guys

  2. #2
    theunlockeRRR is offline Code Child
    Join Date
    Aug 2016
    Location
    Serbia
    Posts
    45
    Rep Power
    0

    Default Re: Multiple UserInput Using JOptionPane.showInputDialog

    First of all, make sure you wrap your code with code tags, so its easier to read and it looks better.
    Not sure if I understood your question but I'll quess I did. So you want to do all these in one window? Then you need to use textfield.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: Multiple UserInput Using JOptionPane.showInputDialog

    The message argument to JOptionPane.showConfirmDialog can be a JPanel with a JLabel and a JTextfield for each data item. You'll need to learn how to layout the panel; look to the Oracle tutorials for that.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. JOptionPane.showInputDialog not appearing properly.
    By peter_62au in forum New To Java
    Replies: 4
    Last Post: 01-17-2014, 10:47 AM
  2. Help with JOptionPane.showInputDialog
    By Rahim2312 in forum New To Java
    Replies: 13
    Last Post: 05-01-2012, 02:10 AM
  3. JOptionPane.showInputDialog with only 1 correct answer
    By Gladiat0r in forum New To Java
    Replies: 1
    Last Post: 03-18-2012, 09:42 PM
  4. JOptionPane.showInputDialog
    By mayhewj7 in forum New To Java
    Replies: 5
    Last Post: 02-25-2009, 06:04 AM
  5. Problem with JOptionPane.showInputDialog()
    By romina in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 05:33 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •