0

I am designing a simple payroll program in which I wish to prompt the user to add an employee object. The employee has several attributes

Employee(String firstName, String lastName, String address, String phoneNum, int employeeIdNum, double wageRate, double hours);

JOptionPane allows me to create separate input prompt windows for each individual variable but that is a lot of windows. I am trying to encompass all the information in one window so the user may fill in all 7 variables without having to hit ok/continue 7 times.

user16771
  • 51
  • 1
  • 1
  • 6
  • Possible duplicate: http://stackoverflow.com/questions/6555040/multiple-input-in-joptionpane-showinputdialog – Kostas Kryptos Nov 10 '15 at 16:47
  • 1
    then i would suggest not using Joptionpane and instead a Dialog/JFrame with a nicer layout of all components – Emerson Cod Nov 10 '15 at 16:50
  • 1
    You can do it with a JOptionPane. The 'message' argument of the 'showInputDialog()' methods can be a JPanel with multiple input text fields in it. – FredK Nov 10 '15 at 16:56

1 Answers1

0

(Not an out-of-the-box solution)

There does exist the BeanInfo API to do just that: adding for any java bean, POJO, a BeanInfo that lists properties. It is used in several IDEs, GUI builders to have components with a property table.

Stand-alone you will need your own component: a JTable with two/three columns, the first a read-only field name, the second an editor for the value, and later maybe a third column for som edit icon.

Such a component can be shown for instance in a custom JOptionPane.

Joop Eggen
  • 107,315
  • 7
  • 83
  • 138