A
apattin
Hi all,
I think we're tied in our underwear here...
(a) My JTable is set to allow cell selection, so I have these
statements when I set up the table:
fpeTable.setRowSelectionAllowed(false);
fpeTable.setColumnSelectionAllowed(false);
fpeTable.setCellSelectionEnabled(true);
things work as advertised.
(b) I also have a mouse listener for column header clicks that
programatically selects all the cells in the column. The cells are
shown with a different background, as wanted.
(c) Now I would like to simulate the effect of
setRowSelectionAllowed(true) in that I'd like to color all the row when
any cell is clicked (selected). So I created a custom renderer that
sets the background of the JLabel component to a different color when a
cell is selected. This works too. However, now if I click on the column
header, the entire table's background is changed. Clearly not what I
want, and I understand why it's happening (because of the custom
renderer sees all cells in the column being selected by the mouse
listener).
How does one fix this? The behavior we want is:
If a cell is selected via a click, simulate selection with the custom
renderer; however, if the cells are selected from the column header
click, just select the column. Can this be done?
Thanks!
Alejandrina
I think we're tied in our underwear here...
(a) My JTable is set to allow cell selection, so I have these
statements when I set up the table:
fpeTable.setRowSelectionAllowed(false);
fpeTable.setColumnSelectionAllowed(false);
fpeTable.setCellSelectionEnabled(true);
things work as advertised.
(b) I also have a mouse listener for column header clicks that
programatically selects all the cells in the column. The cells are
shown with a different background, as wanted.
(c) Now I would like to simulate the effect of
setRowSelectionAllowed(true) in that I'd like to color all the row when
any cell is clicked (selected). So I created a custom renderer that
sets the background of the JLabel component to a different color when a
cell is selected. This works too. However, now if I click on the column
header, the entire table's background is changed. Clearly not what I
want, and I understand why it's happening (because of the custom
renderer sees all cells in the column being selected by the mouse
listener).
How does one fix this? The behavior we want is:
If a cell is selected via a click, simulate selection with the custom
renderer; however, if the cells are selected from the column header
click, just select the column. Can this be done?
Thanks!
Alejandrina