409 // implements javax.swing.table.TableColumnModel
410 /**
411 * Returns true if column selection is allowed, otherwise false.
412 * The default is false.
413 * @return the <code>columnSelectionAllowed</code> property
414 */
415 public boolean getColumnSelectionAllowed() {
416 return columnSelectionAllowed;
417 }
418
419 // implements javax.swing.table.TableColumnModel
420 /**
421 * Returns an array of selected columns. If <code>selectionModel</code>
422 * is <code>null</code>, returns an empty array.
423 * @return an array of selected columns or an empty array if nothing
424 * is selected or the <code>selectionModel</code> is
425 * <code>null</code>
426 */
427 public int[] getSelectedColumns() {
428 if (selectionModel != null) {
429 int iMin = selectionModel.getMinSelectionIndex();
430 int iMax = selectionModel.getMaxSelectionIndex();
431
432 if ((iMin == -1) || (iMax == -1)) {
433 return new int[0];
434 }
435
436 int[] rvTmp = new int[1+ (iMax - iMin)];
437 int n = 0;
438 for(int i = iMin; i <= iMax; i++) {
439 if (selectionModel.isSelectedIndex(i)) {
440 rvTmp[n++] = i;
441 }
442 }
443 int[] rv = new int[n];
444 System.arraycopy(rvTmp, 0, rv, 0, n);
445 return rv;
446 }
447 return new int[0];
448 }
449
450 // implements javax.swing.table.TableColumnModel
451 /**
452 * Returns the number of columns selected.
453 * @return the number of columns selected
454 */
455 public int getSelectedColumnCount() {
456 if (selectionModel != null) {
457 int iMin = selectionModel.getMinSelectionIndex();
458 int iMax = selectionModel.getMaxSelectionIndex();
459 int count = 0;
460
461 for(int i = iMin; i <= iMax; i++) {
462 if (selectionModel.isSelectedIndex(i)) {
463 count++;
464 }
465 }
466 return count;
467 }
468 return 0;
469 }
470
471 //
472 // Listener Support Methods
473 //
474
475 // implements javax.swing.table.TableColumnModel
476 /**
477 * Adds a listener for table column model events.
478 * @param x a <code>TableColumnModelListener</code> object
479 */
480 public void addColumnModelListener(TableColumnModelListener x) {
481 listenerList.add(TableColumnModelListener.class, x);
482 }
483
484 // implements javax.swing.table.TableColumnModel
485 /**
486 * Removes a listener for table column model events.
|
409 // implements javax.swing.table.TableColumnModel
410 /**
411 * Returns true if column selection is allowed, otherwise false.
412 * The default is false.
413 * @return the <code>columnSelectionAllowed</code> property
414 */
415 public boolean getColumnSelectionAllowed() {
416 return columnSelectionAllowed;
417 }
418
419 // implements javax.swing.table.TableColumnModel
420 /**
421 * Returns an array of selected columns. If <code>selectionModel</code>
422 * is <code>null</code>, returns an empty array.
423 * @return an array of selected columns or an empty array if nothing
424 * is selected or the <code>selectionModel</code> is
425 * <code>null</code>
426 */
427 public int[] getSelectedColumns() {
428 if (selectionModel != null) {
429 return selectionModel.getSelectedIndices();
430 }
431 return new int[0];
432 }
433
434 // implements javax.swing.table.TableColumnModel
435 /**
436 * Returns the number of columns selected.
437 * @return the number of columns selected
438 */
439 public int getSelectedColumnCount() {
440 if (selectionModel != null) {
441 return selectionModel.getSelectedItemsCount();
442 }
443 return 0;
444 }
445
446 //
447 // Listener Support Methods
448 //
449
450 // implements javax.swing.table.TableColumnModel
451 /**
452 * Adds a listener for table column model events.
453 * @param x a <code>TableColumnModelListener</code> object
454 */
455 public void addColumnModelListener(TableColumnModelListener x) {
456 listenerList.add(TableColumnModelListener.class, x);
457 }
458
459 // implements javax.swing.table.TableColumnModel
460 /**
461 * Removes a listener for table column model events.
|