Results 1 to 6 of 6
  1. #1
    ajw1993 is offline Member
    Join Date
    Nov 2012
    Posts
    30
    Rep Power
    0

    Default dialog selecting problem?

    I am trying to type in something that would bring up an options dialog box

    problems :
    when trying to open type in the option box to appear it doesnt
    and also when trying to send the data to the external method isnt working either

    public void edit() {
    String employee = "please enter the last name of the employee you want to edit";
    String edit = "Please enter what you would like to edit";

    String employees = JOptionPane.showInputDialog(employee);
    String edits = JOptionPane.showInputDialog(edit);

    for (int i = 0; i < staffs.size(); i++) {
    if (employees.equals(staffs.get(i).getSurname()))
    if (edits.equals("first name")) {
    String firstName = "Please enter the new first name";
    String newFirstName = JOptionPane
    .showInputDialog(firstName);
    staffs.get(i).setFirstName(newFirstName);
    }

    else if (edits.equals("surname")) {
    String surname = "Please enter the new surname";
    String newSurname = JOptionPane.showInputDialog(surname);
    staffs.get(i).setSurname(newSurname);

    } else if (edits.equals("date of birth")) {
    String dob = "Please enter the new date of birth";
    String newDOB = JOptionPane.showInputDialog(dob);
    staffs.get(i).setDOB(newDOB);

    } else if (edits.equals("annual salary")) {
    String annual = "Please enter the annual salary";
    String newAnnual = JOptionPane.showInputDialog(annual);

    int a = Integer.parseInt(newAnnual);
    staffs.get(i).setAnnualSalary(a);

    } else if (edit.equals("role")) {
    Object[] choices = { "manager", "lecuter", "techician" };
    Component frame = null;
    Icon icon = null;
    String s = (String) JOptionPane.showInputDialog(frame,
    "Please enter select new role",

    "Edit The Role", JOptionPane.PLAIN_MESSAGE, icon,
    choices, "manager");
    String newRole = s;

    staffs.get(i).setSelectedRole(newRole);
    }

    }
    }

    }
    }
    Last edited by ajw1993; 12-03-2013 at 06:32 PM. Reason: need to

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,891
    Rep Power
    5

    Default Re: dialog selecting problem?

    You know you've been shown how to properly post formatted code before. If you want people to help you, I suggest you make those tiny tiny little bits of effort.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,523
    Rep Power
    5

    Default Re: dialog selecting problem?

    Please provide an Short, Self Contained, Correct Example that demonstrates the problem. Don't include all of your code. But it must be compilable.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  4. #4
    ajw1993 is offline Member
    Join Date
    Nov 2012
    Posts
    30
    Rep Power
    0

    Default Re: dialog selecting problem?

    Java Code:
    else if (edit.equals("role")) {
    					Object[] choices = { "manager", "lecuter", "techician" };
    					Component frame = null;
    					Icon icon = null;
    					String s = (String) JOptionPane.showInputDialog(frame,
    							"Please enter select new role",
    
    							"Edit The Role", JOptionPane.PLAIN_MESSAGE, icon,
    							choices, "manager");
    					String newRole = s;
    
    				staffs.get(i).setSelectedRole(newRole);
    
    				}
    		}
    
    	}

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,523
    Rep Power
    5

    Default Re: dialog selecting problem?

    That is not compilable. Please provide a small, complete program that demonstrates the problem.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  6. #6
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    356
    Rep Power
    5

    Default Re: dialog selecting problem?

    What are you seeing when you run your code? Is the dialog being displayed?

Similar Threads

  1. problem selecting a chess piece
    By wil3789 in forum New To Java
    Replies: 3
    Last Post: 01-05-2012, 07:18 AM
  2. JTable selecting single row problem
    By ContoNick in forum New To Java
    Replies: 2
    Last Post: 12-31-2011, 02:31 PM
  3. Problem creating dialog box
    By SeanC in forum New To Java
    Replies: 2
    Last Post: 08-13-2010, 05:38 PM
  4. save dialog problem
    By masa in forum AWT / Swing
    Replies: 2
    Last Post: 03-06-2009, 12:41 AM
  5. Problem in dialog
    By Sarinam in forum New To Java
    Replies: 5
    Last Post: 07-12-2008, 11:38 AM

Posting Permissions

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