I am attempting to fabricate a JTable to get behavior similar to Windows
Explorer in Icons view mode.  I am able to rebuild the model, shrinking and
growing the number of columns, as the size of the table's parent changes.  I
have no doubt that I will be able develop a renderer that can make each cell
look appropriate.

I call JTable.setCellSelectionEnabled(true) and
JTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);  I
also integrated code from Java Bug 4314209 that seems to fix a selection
anomaly.

Here's the problem: assume a 3 by 3 table.  I select cell 0,0 and it
correctly gets highlighted.  I hold the control-key down and select 1,1 and,
unfortunately, 0,0 and 0,1 and 1,0 and 1,1 all get selected when I really
just want 0,0 and 1,1.  If I initially select 0,0 and then control-key
select 2,1 the following are selected: 0,0 , 0,1 , 2,0 , 2,1.  

The table utilizes a DefaultListSelectionModel for rows and a separate one
for columns.  DefaultListSelectionModel.addSelectionInterval() explicitly
states that it is going to change the selection to be the union
of the current and the requested selection, and I'm thinking that that union
over the 2 models is the culprit.  I'm looking at DefaultListSelectionModel
with an eye to subclassing it with my own code but it's fairly forbidding so
I figured I'd check with the list.  It's ironic that ctrl-selection is a
problem because I would think that shift-selection (i.e. extending a
selection) would be more difficult.  I'm thinking I might need to somehow
track on my own the control selections and then merge them somehow but who
knows?

I really just want to select random cells and not have ctrl-select select
more than one more additional cell.  Surely others have had this desire and
have confronted this problem. ???  Any suggestions?

thanks much,
rand


--------------------------------
Rand Clark
Software Design Engineer
Transoft Networks
a Hewlett-Packard company
805.883.4315
[EMAIL PROTECTED]
--------------------------------

_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to