I am trying to create an inventory program. And I need help to know how to make
ID: 3640992 • Letter: I
Question
I am trying to create an inventory program. And I need help to know how to make a JComboBox1, a JTextField, and another JComboBox2 work together:For example, in JComboBox1 I have item category; in JComboBox2 i want to display Item description for each category, and in the JTextField i want to display the ID# when an item is selected.
This is the code that I have so far
//add items to jComboBox box;
String[] category = {"Paint Parts", "Trim Out Parts"};
for(int i =0; i< category.length; i++)
box.addItem(category[i]);
//Map to hold Trim Out Parts
final Map<Integer,String > map = new LinkedHashMap<Integer,String>();
map.put(13133, "Nose Plug");
map.put(13000, "Light Kit");
//Map to hold Paint Parts
final Map<Integer, String> paint = new LinkedHashMap<Integer, String>();
paint.put(12103, "Red Primer");
paint.put(12104, "Coal Tar");
Set<Map.Entry<Integer, String>> entrySet = map.entrySet();
for( final Map.Entry<Integer, String> entry: entrySet)
jComboBoxCategory.addItemListener(
new ItemListener(){
public void itemStateChanged(ItemEvent e){
if(e.getStateChange() == ItemEvent.SELECTED)
jComboBoxItemDescription.addItem(entry.getValue());
}
});
The display that I want is;
if user selects Paint Parts, only paint parts should be populated in the jComboBoxItemDescription; and the ID# for the selected item description should be displayed in the JTextField...
I would really appriciate any help, I will rate life saver...