⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaulttablecolumnmodel.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  /**   * getSelectionModel returns selection model   * @return ListSelectionModel selection model   */  public ListSelectionModel getSelectionModel()  {    return selectionModel;  }  /**   * setColumnSelectionAllowed sets whether column selection is allowed   * or not.   *   * @param flag true if column selection is allowed and false otherwise   */  public void setColumnSelectionAllowed(boolean flag)  {    columnSelectionAllowed = flag;  }  /**   * getColumnSelectionAllowed indicates whether column selection is    * allowed or not.   *   * @return boolean true if column selection is allowed and false otherwise.   */  public boolean getColumnSelectionAllowed()  {    return columnSelectionAllowed;  }  /**   * getSelectedColumns returns array containing indexes of currently    * selected columns   *   * @return int[] array containing indexes of currently selected columns   */  public int[] getSelectedColumns()  {    // FIXME: Implementation of this method was taken from private method     // JTable.getSelections(), which is used in various places in JTable    // including selected row calculations and cannot be simply removed.    // This design should be improved to illuminate duplication of code.        ListSelectionModel lsm = this.selectionModel;        int sz = getSelectedColumnCount();    int [] ret = new int[sz];    int lo = lsm.getMinSelectionIndex();    int hi = lsm.getMaxSelectionIndex();    int j = 0;    java.util.ArrayList ls = new java.util.ArrayList();    if (lo != -1 && hi != -1)      {        switch (lsm.getSelectionMode())          {          case ListSelectionModel.SINGLE_SELECTION:            ret[0] = lo;            break;                      case ListSelectionModel.SINGLE_INTERVAL_SELECTION:                        for (int i = lo; i <= hi; ++i)              ret[j++] = i;            break;                      case ListSelectionModel.MULTIPLE_INTERVAL_SELECTION:                    for (int i = lo; i <= hi; ++i)              if (lsm.isSelectedIndex(i))                        ret[j++] = i;            break;          }      }    return ret;  }  /**   * getSelectedColumnCount returns number of currently selected columns   * @return int number of currently selected columns   */  public int getSelectedColumnCount()  {    // FIXME: Implementation of this method was taken from private method     // JTable.countSelections(), which is used in various places in JTable    // including selected row calculations and cannot be simply removed.    // This design should be improved to illuminate duplication of code.       ListSelectionModel lsm = this.selectionModel;    int lo = lsm.getMinSelectionIndex();    int hi = lsm.getMaxSelectionIndex();    int sum = 0;        if (lo != -1 && hi != -1)      {        switch (lsm.getSelectionMode())          {          case ListSelectionModel.SINGLE_SELECTION:            sum = 1;            break;                      case ListSelectionModel.SINGLE_INTERVAL_SELECTION:            sum = hi - lo + 1;            break;                      case ListSelectionModel.MULTIPLE_INTERVAL_SELECTION:                    for (int i = lo; i <= hi; ++i)              if (lsm.isSelectedIndex(i))                        ++sum;            break;          }      }          return sum;  }  /**   * addColumnModelListener adds specified listener to the model's   * listener list   *   * @param listener the listener to add   */  public void addColumnModelListener(TableColumnModelListener listener)  {    listenerList.add(TableColumnModelListener.class, listener);  }  /**   * removeColumnModelListener removes specified listener from the model's    * listener list.   *   * @param listener the listener to remove   */  public void removeColumnModelListener(TableColumnModelListener listener)  {    listenerList.remove(TableColumnModelListener.class, listener);  }  /**   * @since 1.4   */  public TableColumnModelListener[] getColumnModelListeners()  {    return (TableColumnModelListener[])      listenerList.getListeners(TableColumnModelListener.class);  }	    /**   * fireColumnAdded fires TableColumnModelEvent to registered    * TableColumnModelListeners to indicate that column was added   *   * @param e TableColumnModelEvent   */  protected void fireColumnAdded(TableColumnModelEvent e)  {        TableColumnModelListener[] listeners = getColumnModelListeners();    for (int i=0; i< listeners.length; i++)      listeners[i].columnAdded(e);          }  /**   * fireColumnAdded fires TableColumnModelEvent to registered    * TableColumnModelListeners to indicate that column was removed   *   * @param e TableColumnModelEvent   */  protected void fireColumnRemoved(TableColumnModelEvent e)  {    TableColumnModelListener[] listeners = getColumnModelListeners();    for (int i=0; i< listeners.length; i++)      listeners[i].columnRemoved(e);          }  /**   * fireColumnAdded fires TableColumnModelEvent to registered    * TableColumnModelListeners to indicate that column was moved   *   * @param e TableColumnModelEvent   */  protected void fireColumnMoved(TableColumnModelEvent e)  {    TableColumnModelListener[] listeners = getColumnModelListeners();    for (int i=0; i< listeners.length; i++)      listeners[i].columnMoved(e);          }  /**   * fireColumnSelectionChanged fires TableColumnModelEvent to model's   * registered TableColumnModelListeners to indicate that different column    * was selected.   *   * @param evt ListSelectionEvent   */  protected void fireColumnSelectionChanged(ListSelectionEvent evt)  {    EventListener [] listeners = getListeners(TableColumnModelListener.class);    for (int i = 0; i < listeners.length; ++i)      ((TableColumnModelListener)listeners[i]).columnSelectionChanged(evt);  }  /**   * fireColumnMarginChanged fires TableColumnModelEvent to model's   * registered TableColumnModelListeners to indicate that column margin   * was changed.   */  protected void fireColumnMarginChanged()  {    EventListener [] listeners = getListeners(TableColumnModelListener.class);    for (int i = 0; i < listeners.length; ++i)      ((TableColumnModelListener)listeners[i]).columnMarginChanged(changeEvent);  }  /**   * getListeners returns currently registered listeners with this model.   * @param listenerType type of listeners to return   *   * @return EventListener[] array of model's listeners of the specified type   */  public EventListener[] getListeners(Class listenerType)  {    return listenerList.getListeners(listenerType);  }  /**   * propertyChange handles changes occuring in the properties of the   * model's columns.    *   * @param evt PropertyChangeEvent   */  public void propertyChange(PropertyChangeEvent evt)  {    if (evt.getPropertyName().equals(TableColumn.COLUMN_WIDTH_PROPERTY))	invalidateWidthCache();   }  /**   * valueChanged handles changes in the selectionModel.   * @param e ListSelectionEvent   */  public void valueChanged(ListSelectionEvent e)  {    fireColumnSelectionChanged(e);  }  /**   * createSelectionModel creates selection model that will keep track   * of currently selected column(s)   *   * @return ListSelectionModel selection model of the columns   */  protected ListSelectionModel createSelectionModel()  {        return new DefaultListSelectionModel();  }  /**   * recalcWidthCache calculates total width of the columns.   * If the current cache of the total width is in invalidated state,    * then width is recalculated. Otherwise nothing is done.   */  protected void recalcWidthCache()  {    if (totalColumnWidth == -1)      {        totalColumnWidth = 0;        for (int i = 0; i < tableColumns.size(); ++i)          {            totalColumnWidth += ((TableColumn)tableColumns.get(i)).getWidth();          }      }  }  /**   * invalidateWidthCache   */  private void invalidateWidthCache()  {    totalColumnWidth = -1;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -