Search code examples
javaswingjcomboboxjtextfieldnetbeans-6.9

linking jcombobox values with jtextfield values


I've created an application in netbeans IDE 6.9 where I need to set values for each value in the jcombobox. In my pane I've a combobox and below that are the textfields for entering values for each value in the combobox. Can anyone suggest that how do I link the combobox with textfield. I mean there are different values for each value in the combobox. I want that user selects a value in the combobox then its corresponding value should be displayed(if it has already been entered) otherwise a blank space should be shown. I want that all the values for each combobox values should be set in one go(the user should not press the ok button). -Thanks in advance


Solution

  • I can only guess from the question that each item in your combo box is an object and you want to edit multiple fields of the selected item.

    You could use a bunch of individual text fields, one for each "value" in the selected "value in the combobox".

    A better UI would be a property pane to list and edit the fields. The commercial PropertyGrid in JIDE Grids can actually combine the combobox and property pane in one place.

    You can commit each field value after it is entered, or commit all when the editor loses focus (for example when you select another item in the combo).