Home arrow static arrow Java Programming [Archive] - Jtable row selection problem
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Jtable row selection problem
This topic has 2 replies on 1 page.

Posts:1
Registered: 8/27/03
Jtable row selection problem  
Aug 27, 2003 1:37 PM



 
Hi,

I have a Jtable with multible rows. Whenever I select one of the rows I noticed that the row is blue. But the particular cell I click on is white.

Is there a way I can fixed this problem/

Here is a snippet of my code:

jtable = new JTable(dtmPrinters);
ListSelectionModel rowSM = jtable.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()) {
System.out.println("No rows are selected.");
}
else {
int selectedRow = lsm.getMinSelectionIndex();
printname = (String)dtmPrinters.getValueAt(selectedRow, 0);
}
}
});

// jtable.setEnabled(false);
jtable.getTableHeader().setResizingAllowed(false);
jtable.getTableHeader().setReorderingAllowed(false);
jtable.setRowSelectionAllowed(true);
jtable.setColumnSelectionAllowed(false);
jtable.setCellSelectionEnabled(false);
jtable.setShowHorizontalLines(false);
jtable.setRowSelectionAllowed(true);
jtable.setShowVerticalLines(false);
jtable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jtable.setShowGrid(false);
jtable.setRowHeight(20);
jtable.getTableHeader().setReorderingAllowed( false );
jtable.setIntercellSpacing(new Dimension(0,0) );
jtable.createDefaultColumnsFromModel();
MyRenderer renderer = new MyRenderer();
jtable.setDefaultRenderer(Object.class, renderer);

---thanks
 

Posts:9
Registered: 2/10/03
Re: Jtable row selection problem  
Nov 22, 2003 8:17 AM (reply 1 of 2)



 
Hi,

I have the same problem and I'm still looking for an answer to resolve it.

Did you find the solution so far ?

Please let me know it.
 

Posts:7
Registered: 12/11/00
Re: Jtable row selection problem  
Jun 27, 2004 7:01 PM (reply 2 of 2)



 
I have a table in which I basically want to highlight an entire row, and not show the column selected. I do this by using my own renderer that "highlights" each cell of a row in the same way when any cell of that row is selected. I don't render the selected cell in any special way, so as a result the column selection is hidden.
 
This topic has 2 replies on 1 page.