
Signature
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')
aleicaro@libero.it wrote:
> Hi,
> I have the following problem
[quoted text clipped - 11 lines]
> JTable is not possible to select non consequentials single cells. For
> example I need to select the cell "2" and the cell "4.30".
Really? It looks like JTable's setSelectionMode method allows the
following choices by default:
SINGLE_SELECTION
SINGLE_INTERVAL_SELECTION
MULTIPLE_INTERVAL_SELECTION
It sounds like MULTIPLE_INTERVAL_SELECTION is just what you want.

Signature
Thomas A. Russ, USC/Information Sciences Institute
Thomas Weidenfeller - 21 Jun 2005 08:05 GMT
> Really? It looks like JTable's setSelectionMode method allows the
> following choices by default:
[quoted text clipped - 4 lines]
>
> It sounds like MULTIPLE_INTERVAL_SELECTION is just what you want.
You apparently never used it. Some "genius" at Sun decided to model the
selection with a combination of a row selection (ListSelectionModel),
and a column selection (ListSelectionModel in TableColumnModel). If you
work with setCellSelectionEnabled a cell is considered to be selected if
its row is marked as selected in the row selection model, and its column
is marked as selected in the column selection model. In other words, the
intersections of row/column selections are treated as a cell selections.
This works fine if there is only one cell to be selected or one
consecutive interval. The mechanism breaks down immediately if you want
to select more than one cell that are not directly neighbours. Because
you end up not only with the desired cells selected, but also with the
set union of all row/column combinations selected. E.g.
Assume you want to select cell (0,0), and cell (10,10). So row 0 and row
10 get marked as selected in the row selection model. And column 0 and
column 10 get marked as selected in the column selection model. But this
means, that also cell (0,10) and (10.0) are considered to be selected.
MULTIPLE_INTERVAL_SELECTION is pretty much irrelevant, because if you
use more than just on selection interval, you get phantom selections. If
you use a single selection interval it happens that the phantom
selections are also desired selections.
There are good reasons why JTable is in general considered to be the
worst Swing component of all (closely followed by JFileChooser). The
above is one of these reasons.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
Thank you,
yes I tried to build a panel with a grid layout with 24x2 cells, but I
would like to use something more "pretty" than checkbox. I would like
grid cells that are selected on mouse over...I would like a serie of
squares...how can I realize it?