JTable with row selection, but no cell selection

  • Follow


I have a JTable where I want the user to be able to select a row, but not a
single cell. If the user clicks on a cell, the entire row should be
highlighted (=different background color), but the CellEditor shouldn't come
up.

JTable table = new JTable();

// this wil disable cell selection, but also the row
// highlighting disappears
table.setCellSelectionEnabled(false);

Thanks
Simon


0
Reply Simon 1/4/2005 7:48:59 PM

>I have a JTable where I want the user to be able to select a row, but not a
> single cell. If the user clicks on a cell, the entire row should be
> highlighted (=different background color), but the CellEditor shouldn't 
> come
> up.
>
> JTable table = new JTable();
>
> // this wil disable cell selection, but also the row
> // highlighting disappears
> table.setCellSelectionEnabled(false);

table.setRowSelectionAllowed(true);

-- 
Andrey Kuznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities


0
Reply Andrey 1/5/2005 3:35:41 AM


Followup-To: comp.lang.java.gui.

Simon Niederberger <simon@sincore.ch> wrote:

> I have a JTable where I want the user to be able to select a row, but not a
> single cell. If the user clicks on a cell, the entire row should be
> highlighted (=different background color), but the CellEditor shouldn't come
> up.

You a) change the renderer not to paint editable cells in a special
background color and b) configure the editor not to start editing
on single mouse clicks.


Christian
0
Reply usenet 1/7/2005 4:17:40 PM

2 Replies
587 Views

(page loaded in 0.035 seconds)

Similiar Articles:













7/23/2012 8:52:05 AM


Reply: