jdk/src/share/classes/javax/swing/JTable.java
changeset 5590 3ec077d7e893
parent 5449 21bec46ee9e3
child 5597 ab490f66d2cf
equal deleted inserted replaced
5589:5e4f59f34eea 5590:3ec077d7e893
  2581      * @return  the index of the corresponding column in the model
  2581      * @return  the index of the corresponding column in the model
  2582      *
  2582      *
  2583      * @see #convertColumnIndexToView
  2583      * @see #convertColumnIndexToView
  2584      */
  2584      */
  2585     public int convertColumnIndexToModel(int viewColumnIndex) {
  2585     public int convertColumnIndexToModel(int viewColumnIndex) {
  2586         if (viewColumnIndex < 0) {
  2586         return SwingUtilities2.convertColumnIndexToModel(
  2587             return viewColumnIndex;
  2587                 getColumnModel(), viewColumnIndex);
  2588         }
       
  2589         return getColumnModel().getColumn(viewColumnIndex).getModelIndex();
       
  2590     }
  2588     }
  2591 
  2589 
  2592     /**
  2590     /**
  2593      * Maps the index of the column in the table model at
  2591      * Maps the index of the column in the table model at
  2594      * <code>modelColumnIndex</code> to the index of the column
  2592      * <code>modelColumnIndex</code> to the index of the column
  2601      * @return   the index of the corresponding column in the view
  2599      * @return   the index of the corresponding column in the view
  2602      *
  2600      *
  2603      * @see #convertColumnIndexToModel
  2601      * @see #convertColumnIndexToModel
  2604      */
  2602      */
  2605     public int convertColumnIndexToView(int modelColumnIndex) {
  2603     public int convertColumnIndexToView(int modelColumnIndex) {
  2606         if (modelColumnIndex < 0) {
  2604         return SwingUtilities2.convertColumnIndexToView(
  2607             return modelColumnIndex;
  2605                 getColumnModel(), modelColumnIndex);
  2608         }
       
  2609         TableColumnModel cm = getColumnModel();
       
  2610         for (int column = 0; column < getColumnCount(); column++) {
       
  2611             if (cm.getColumn(column).getModelIndex() == modelColumnIndex) {
       
  2612                 return column;
       
  2613             }
       
  2614         }
       
  2615         return -1;
       
  2616     }
  2606     }
  2617 
  2607 
  2618     /**
  2608     /**
  2619      * Maps the index of the row in terms of the
  2609      * Maps the index of the row in terms of the
  2620      * <code>TableModel</code> to the view.  If the contents of the
  2610      * <code>TableModel</code> to the view.  If the contents of the