I have a problem with ListSelectionListener with the row selection it's
alright but ones I combine the Column Selection procedure doesn't like it,
throws ArrayIndexOutOfBounds....
pleas any suggestions would be gratefully
appreciated, thanx in advance.
<p>
public final void valueChanged
(ListSelectionEvent e) {
ListSelectionModel lsm
table.getColumnModel().getSelectionModel();
if (e.getValueIsAdjusting()) {
System.out.println("value is
adjusting...");
}
int[] cols = table.getSelectedColumns();
if (cols != null) {
// selectedRow is selected
int minSelectedCol =
lsm.getMinSelectionIndex();
int maxSelectedCol =
lsm.getMaxSelectionIndex();
selectedData = new
Object[table.getRowCount()][cols.length];
System.out.println("selectedData:");
int counter = 0;
for (int j = minSelectedCol; j <=
maxSelectedCol; j++) {
selectedData[counter] =
(Object[])_data.elementAt(j);
counter++;
}
}
public final void insertNewSnapTime(String snapTime, int index) {
int insertionIndex = 0;
insertionIndex = index;
DefaultTableModel colModel = new DefaultTableModel();
TableColumnModel col = null;
// table.getSelectedColumns();
System.out.println("colModel" + colModel);
try {
int colCount = colModel.getColumnCount();
int[] selCol = table.getSelectedColumns();
int selCount = col.getSelectedColumnCount();
String[] _times = null;
// _header = new String[_colTypes.length];
_times = new String[_header.length+1];
// _header = _times;
System.out.println("times: "+_times);
for(int i=0; i<_header.length; i++) {
if (_header[i].compareTo(snapTime) <=
0) {
insertionIndex = i;
System.out.println("times:
"+_times[i]);
break;
}//sets the insertion index
insertionIndex = i;
}
// constructs an extra cell to insert new times\values
Object[] newTimes = new Object[_header.length+1];
System.out.println("times: "+newTimes);
if (insertionIndex > 0) {
System.arraycopy(_times, 0, newTimes, 0,
insertionIndex);
}
newTimes[insertionIndex] = snapTime;
//inserts an extra cell merged at right position,
if (insertionIndex <_times.length-1) {
System.arraycopy(_times,
insertionIndex,
newTimes,
insertionIndex+1,
_times.length-insertionIndex);
}
Object time = null;
colModel.addColumn(time, newTimes);
}catch(Exception e) {
e.printStackTrace();
System.out.println(e);
}
fireTableStructureChanged();
}
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing