I want to take the selection from a JComboBox and have it highlight
the corresponding row in a JTable. I don't have a clue as to how
to do this. I currently have an array of Airport"NAMES" that are
listed in the combo box. I also have an array of Airport "Codes"
that correspond to the respective airportName. In my code, I update
a label to show the correct Airport Code. I want to take this
airport code and have it reflect (highlight and focus gotten)the
corresponding row in my table. Once I get the correct row selected
in the table, I need to use data from each of the fields in the
selected row to update other labels on my GUI.
In my table, the first column of the table has airport "CODES".
I have an itemListener on my ComboBox, but not sure how to have it
interact with the table. The updating of the label to the correct
Airport code works correctly.
//ADD ITEMListener to Airport Combo Box
cbAirport.addItemListener(new ItemListener(){
public void itemStateChanged (ItemEvent e)
{
if (e.getStateChange() == ItemEvent.SELECTED)
{
// Process airport selection:
for(int x=0; x < airports.length; x++ )
{
ACodeLabel.setText("Airport Code: "+
airportCodes[cbAirport.getSelectedIndex()]);
break;
}
repaint();
}//end of if statement
}//end of itemStateChanged
});