<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/*
 * @(#)TableColumnModel.java	1.20 00/02/02
 *
 * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * This software is the proprietary information of Sun Microsystems, Inc.  
 * Use is subject to license terms.
 * 
 */

package javax.swing.table;

import java.util.Enumeration;
import javax.swing.event.ChangeEvent;
import javax.swing.event.*;
import javax.swing.*;


/**
 * Defines the requirements for a table column model object suitable for
 * use with &lt;code&gt;JTable&lt;/code&gt;.
 *
 * @version 1.20 02/02/00
 * @author Alan Chung
 * @author Philip Milne
 * @see DefaultTableColumnModel
 */
public interface TableColumnModel
{
//
// Modifying the model
//

    /**
     *  Appends &lt;code&gt;aColumn&lt;/code&gt; to the end of the
     *  &lt;code&gt;tableColumns&lt;/code&gt; array.
     *  This method posts a &lt;code&gt;columnAdded&lt;/code&gt;
     *  event to its listeners.
     *
     * @param   aColumn         the &lt;code&gt;TableColumn&lt;/code&gt; to be added
     * @see     #removeColumn
     */
    public void addColumn(TableColumn aColumn);

    /**
     *  Deletes the &lt;code&gt;TableColumn&lt;/code&gt; &lt;code&gt;column&lt;/code&gt; from the 
     *  &lt;code&gt;tableColumns&lt;/code&gt; array.  This method will do nothing if 
     *  &lt;code&gt;column&lt;/code&gt; is not in the table's column list.
     *  This method posts a &lt;code&gt;columnRemoved&lt;/code&gt;
     *  event to its listeners.
     *
     * @param   column          the &lt;code&gt;TableColumn&lt;/code&gt; to be removed
     * @see     #addColumn
     */
    public void removeColumn(TableColumn column);
    
    /**
     * Moves the column and its header at &lt;code&gt;columnIndex&lt;/code&gt; to
     * &lt;code&gt;newIndex&lt;/code&gt;.  The old column at &lt;code&gt;columnIndex&lt;/code&gt;
     * will now be found at &lt;code&gt;newIndex&lt;/code&gt;.  The column that used
     * to be at &lt;code&gt;newIndex&lt;/code&gt; is shifted left or right
     * to make room.  This will not move any columns if
     * &lt;code&gt;columnIndex&lt;/code&gt; equals &lt;code&gt;newIndex&lt;/code&gt;.  This method 
     * posts a &lt;code&gt;columnMoved&lt;/code&gt; event to its listeners.
     *
     * @param   columnIndex                     the index of column to be moved
     * @param   newIndex                        index of the column's new location
     * @exception IllegalArgumentException      if &lt;code&gt;columnIndex&lt;/code&gt; or 
     *                                          &lt;code&gt;newIndex&lt;/code&gt;
     *                                          are not in the valid range
     */
    public void moveColumn(int columnIndex, int newIndex);

    /**
     * Sets the &lt;code&gt;TableColumn&lt;/code&gt;'s column margin to
     * &lt;code&gt;newMargin&lt;/code&gt;.  This method posts
     * a &lt;code&gt;columnMarginChanged&lt;/code&gt; event to its listeners.
     *
     * @param   newMargin       the width, in pixels, of the new column margins
     * @see     #getColumnMargin
     */
    public void setColumnMargin(int newMargin);
    
//
// Querying the model
//

    /** 
     * Returns the number of columns in the model.
     * @return the number of columns in the model
     */
    public int getColumnCount();
    
    /** 
     * Returns an &lt;code&gt;Enumeration&lt;/code&gt; of all the columns in the model.
     * @return an &lt;code&gt;Enumeration&lt;/code&gt; of all the columns in the model
     */
    public Enumeration getColumns();

    /**
     * Returns the index of the first column in the table
     * whose identifier is equal to &lt;code&gt;identifier&lt;/code&gt;,
     * when compared using &lt;code&gt;equals&lt;/code&gt;.
     *
     * @param           columnIdentifier        the identifier object
     * @return          the index of the first table column
     *                  whose identifier is equal to &lt;code&gt;identifier&lt;/code&gt;
     * @exception IllegalArgumentException      if &lt;code&gt;identifier&lt;/code&gt;
     *				is &lt;code&gt;null&lt;/code&gt;, or no
     *				&lt;code&gt;TableColumn&lt;/code&gt; has this
     *				&lt;code&gt;identifier&lt;/code&gt;
     * @see             #getColumn
     */
    public int getColumnIndex(Object columnIdentifier);

    /**
     * Returns the &lt;code&gt;TableColumn&lt;/code&gt; object for the column at
     * &lt;code&gt;columnIndex&lt;/code&gt;.
     *
     * @param   columnIndex     the index of the desired column 
     * @return  the &lt;code&gt;TableColumn&lt;/code&gt; object for
     *				the column at &lt;code&gt;columnIndex&lt;/code&gt;
     */
    public TableColumn getColumn(int columnIndex);

    /** 
     * Returns the width between the cells in each column. 
     * @return the margin, in pixels, between the cells
     */
    public int getColumnMargin();
    
    /**
     * Returns the index of the column that lies on the 
     * horizontal point, &lt;code&gt;xPosition&lt;/code&gt;;
     * or -1 if it lies outside the any of the column's bounds.
     *
     * @return  the index of the column; or -1 if no column is found
     */
    public int getColumnIndexAtX(int xPosition);
    
    /** 
     * Returns the total width of all the columns. 
     * @return the total computed width of all columns
     */
    public int getTotalColumnWidth();

//
// Selection
//

    /**
     * Sets whether the columns in this model may be selected.
     * @param flag   true if columns may be selected; otherwise false
     * @see #getColumnSelectionAllowed
     */
    public void setColumnSelectionAllowed(boolean flag);

    /**
     * Returns true if columns may be selected.
     * @return true if columns may be selected
     * @see #setColumnSelectionAllowed
     */
    public boolean getColumnSelectionAllowed();

    /**
     * Returns an array of indicies of all selected columns.
     * @return an array of integers containing the indicies of all
     *		selected columns; or an empty array if nothing is selected
     */
    public int[] getSelectedColumns();

    /**
     * Returns the number of selected columns.
     *
     * @return the number of selected columns; or 0 if no columns are selected
     */
    public int getSelectedColumnCount();

    /**
     * Sets the selection model.
     *
     * @param newModel  a &lt;code&gt;ListSelectionModel&lt;/code&gt; object
     * @see #getSelectionModel
     */
    public void setSelectionModel(ListSelectionModel newModel); 
    
    /**
     * Returns the current selection model.
     *
     * @return a &lt;code&gt;ListSelectionModel&lt;/code&gt; object 
     * @see #setSelectionModel
     */
    public ListSelectionModel getSelectionModel(); 
    
//
// Listener
//

    /**
     * Adds a listener for table column model events.
     *
     * @param x  a &lt;code&gt;TableColumnModelListener&lt;/code&gt; object
     */
    public void addColumnModelListener(TableColumnModelListener x);

    /**
     * Removes a listener for table column model events.
     *
     * @param x  a &lt;code&gt;TableColumnModelListener&lt;/code&gt; object
     */
    public void removeColumnModelListener(TableColumnModelListener x);
}
</pre></body></html>