Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Elliott Jones   on Mar 04 In Java Category.

  
Question Answered By: Ana Silva   on Mar 04

I forgot to also show  my code  for my JTable (airportStuff). This is
where I think I should be coding for highlighting selected row
utilizing the value that is obtained by this:

airportCodes [cbAirport.getSelectedIndex()];

Here's my table  airportStuff listSelection Listener:

/**/
airportStuff.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
if (ALLOW_ROW_SELECTION) { // true by default
ListSelectionModel rowSM = airportStuff.getSelectionModel
();
rowSM.addListSelectionListener(new ListSelectionListener
() {
public void  valueChanged(ListSelectionEvent e) {
//Ignore extra messages.
if (e.getValueIsAdjusting()) return;

ListSelectionModel lsm = (ListSelectionModel)
e.getSource();
if (lsm.isSelectionEmpty()) {
return;
} else {
int selectedRow = lsm.getMinSelectionIndex();
airportStuff.setSelectionBackground
(Color.yellow);
}
}
});
} else {
airportStuff.setRowSelectionAllowed(false);
}
/* */

Share: 

 
 
Didn't find what you were looking for? Find more on Need Help on JComboBox and JTable interaction Or get search suggestion and latest updates.


Tagged: