JIDE 3.5.15

com.jidesoft.grid
Class TableColumnChooser

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by com.jidesoft.grid.TableColumnChooser
All Implemented Interfaces:
ActionListener, MouseListener, MouseMotionListener, MouseWheelListener, PropertyChangeListener, EventListener

public class TableColumnChooser
extends MouseAdapter
implements ActionListener, PropertyChangeListener

TableColumnChooser's show/hide column popup menu feature is replaced by TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information. In short, here is the new code to produce the same result as the TabelColumnChooser.

 TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(_table);
 installer.addTableHeaderPopupMenuCustomizer(new AutoResizePopupMenuCustomizer());
 installer.addTableHeaderPopupMenuCustomizer(new TableColumnChooserPopupMenuCustomizer());
 

Author:
Santhosh Kumar T, JIDE Software, Inc.

Field Summary
static String CLICK_COLUMN_INDEX
          Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
static String CLIENT_PROPERTY_COLUMN_CHOOSER_DIALOG_STYLE
          Since 2.10.1, we use DualList in TableColumnChooserDialog.
static String CLIENT_PROPERTY_COLUMN_SORT_ORDER
          You can set this client property for your table to SortableListModel.SORT_ASCENDING, SortableListModel.SORT_DESCENDING or SortableListModel.UNSORTED.
static String CLIENT_PROPERTY_HIDDEN_IDENTIFIER_LIST
          When hideColumn(javax.swing.JTable, int) or showColumn(javax.swing.JTable, String, int, int) is invoked, we will update the hidden identifier list so that you could locate the list of the hidden identifiers.
static String CLIENT_PROPERTY_TABLE_CHANGED
          When grouping or ungrouping, JideTable.tableChanged(TableModelEvent) is called, we will call the code below to save the information that the table is changed.
static String CLIENT_PROPERTY_TABLE_COLUMN_IDENTIFIER
          When hideColumn(javax.swing.JTable, int) is called, we will call the code below to save the original column.
static String CLIENT_PROPERTY_TABLE_COLUMN_INDEX
          Deprecated. 
static String CLIENT_PROPERTY_TABLE_COLUMN_NAME
          Deprecated. 
static String CLIENT_PROPERTY_TABLE_COLUMN_WIDTH_RESET
          By default, column width will not be reset when choosing "reset to default".
static String COLUMN_INDEX
          Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
static String DISPLAY_COLUMN_NAMES
          Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
static String FIXED_COLUMNS
          Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
static String HIDDEN_COLUMNS
          Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
static String SHOW_AUTO_RESIZE
          Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
static String SHOW_SELECTION
          Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
static String TABLE
          Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
static String TABLE_COLUMN_CHOOSER
          Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
 
Constructor Summary
TableColumnChooser()
          Deprecated. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
 
Method Summary
 void actionPerformed(ActionEvent e)
           
protected  void createColumnChooserMenuItems(JPopupMenu popup, JTableHeader header, int[] fixedColumns, int clickingColumn)
          Deprecated. This method is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
protected  void createColumnChooserMenuItems(JPopupMenu popup, JTableHeader header, int[] fixedColumns, int[] hiddenColumns, int clickingColumn)
          Deprecated. This method is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
static int getActualIndex(JTable table, int columnIndex)
          Get actual index from the model index in table scroll pane scenario.
static JTable getActualTable(JTable table, int modelIndex)
          Get actual table instance from the model index in table scroll pane scenario.
static int[] getAllHiddenColumns(JTable table)
          Gets all the hidden columns.
static JTable[] getAllTables(JTable table)
          Get all table instances from any one table in table scroll pane scenario.
static int getColumnIndex(TableColumnModel model, int modelCol)
          Gets the index of the column in the specified TableColumnModel.
static int getColumnIndex(TableColumnModel model, TableColumn col)
          Gets the view index of the column in the specified TableColumnModel.
protected  String getDisplayColumnName(JTable table, int columnIndex)
          Gets the display column name to be displayed on the popup menu.
static AbstractButton getTableColumnChooserButton(JTable table)
          Gets the table column chooser button so that you can add it to the JScrollPane.UPPER_RIGHT_CORNER of a JScrollPane.
static AbstractButton getTableColumnChooserButton(JTable table, boolean[] hidableColumns)
          Gets a button which will invoke a TableColumnChooserDialog to allow user show or hide columns.
static AbstractButton getTableColumnChooserButton(JTable table, boolean[] hidableColumns, String[] descriptions)
          Gets a button which will invoke a TableColumnChooserDialog to allow user show or hide columns.
static AbstractButton getTableColumnChooserButton(JTable table, int[] fixedColumns, int[] hiddenColumns, String[] descriptions)
          Gets a button which will invoke a TableColumnChooserDialog to allow user show or hide columns.
static AbstractButton getTableColumnChooserButton(JTable table, int[] fixedColumns, String[] descriptions)
          Gets a button which will invoke a TableColumnChooserDialog to allow user show or hide columns.
static AbstractButton getTableColumnChooserButton(JTable table, String[] descriptions)
          Gets a button which will invoke a TableColumnChooserDialog to allow user show or hide columns.
static TableColumnChooserDialog getTableColumnChooserDialog(Dialog parent, JTable table, boolean[] hidableColumns, String[] descriptions)
          Gets the TableColumnChooserDialog for the table.
static TableColumnChooserDialog getTableColumnChooserDialog(Dialog parent, JTable table, int[] fixedColumns, int[] hiddenColumns, String[] descriptions)
          Gets the TableColumnChooserDialog for the table.
static TableColumnChooserDialog getTableColumnChooserDialog(Dialog parent, JTable table, int[] fixedColumns, String[] descriptions)
          Gets the TableColumnChooserDialog for the table.
static TableColumnChooserDialog getTableColumnChooserDialog(Frame parent, JTable table, boolean[] hidableColumns, String[] descriptions)
          Gets the TableColumnChooserDialog for the table.
static TableColumnChooserDialog getTableColumnChooserDialog(Frame parent, JTable table, int[] fixedColumns, int[] hiddenColumns, String[] descriptions)
          Gets the TableColumnChooserDialog for the table.
static TableColumnChooserDialog getTableColumnChooserDialog(Frame parent, JTable table, int[] fixedColumns, String[] descriptions)
          Gets the TableColumnChooserDialog for the table.
static Set<Integer> getVisibleColumns(JTable table)
          Gets a Set of column indices that are visible.
static Set<Integer> getVisibleColumns(JTable table, boolean considerTableScrollPane)
          Gets a Set of column indices that are visible.
static boolean hasHiddenColumns(JTable table)
          Checks if the table has hidden columns.
static void hideColumn(JTable table, int modelIndex)
          Hides the table column at the specified index.
static void hideColumns(JTable table, int[] modelColumnIndexes)
          Hides the columns at specified indices.
static TableColumnChooser install(JTable table)
          Deprecated. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
 boolean isKeepColumnOrder()
          Deprecated. This method is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
static boolean isVisibleColumn(JTable table, int modelIndex)
          Checks if a column is visible.
static boolean isVisibleColumn(TableColumnModel model, int modelCol)
          Checks if a column is visible.
static boolean isVisibleColumn(TableColumnModel model, TableColumn col)
          Checks if a column is visible.
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void propertyChange(PropertyChangeEvent evt)
           
static void reorderColumns(JTable table, int[] visibleModelIndices)
          Reorder the columns according the visible column index array.
static void resetColumnsToDefault(JTable table)
          Reset the visible columns to all the columns in table model and clear all previous hiding actions.
 void setKeepColumnOrder(boolean keepColumnOrder)
          Deprecated. This method is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
static void showAllColumns(JTable table)
          Shows all columns that were hidden.
static void showColumn(JTable table, int modelIndex, int viewIndex)
          Shows the TableColumn at the specified column index.
static void showColumn(JTable table, String columnIdentifier, int modelIndex, int newColumnIndex)
          Shows the TableColumn with the specified name.
static void showColumns(JTable table, int[] modelColumnIndexes)
          Shows the columns at specified indices.
static void uninstall(JTable table)
          Deprecated. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
 
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseWheelMoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIXED_COLUMNS

@Deprecated
public static final String FIXED_COLUMNS
Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
See Also:
Constant Field Values

HIDDEN_COLUMNS

@Deprecated
public static final String HIDDEN_COLUMNS
Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
See Also:
Constant Field Values

SHOW_AUTO_RESIZE

@Deprecated
public static final String SHOW_AUTO_RESIZE
Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
See Also:
Constant Field Values

SHOW_SELECTION

@Deprecated
public static final String SHOW_SELECTION
Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
See Also:
Constant Field Values

DISPLAY_COLUMN_NAMES

@Deprecated
public static final String DISPLAY_COLUMN_NAMES
Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
See Also:
Constant Field Values

COLUMN_INDEX

@Deprecated
public static final String COLUMN_INDEX
Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
See Also:
Constant Field Values

CLICK_COLUMN_INDEX

@Deprecated
public static final String CLICK_COLUMN_INDEX
Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
See Also:
Constant Field Values

TABLE

@Deprecated
public static final String TABLE
Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
See Also:
Constant Field Values

TABLE_COLUMN_CHOOSER

@Deprecated
public static final String TABLE_COLUMN_CHOOSER
Deprecated. This client property is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.
See Also:
Constant Field Values

CLIENT_PROPERTY_TABLE_COLUMN_NAME

@Deprecated
public static final String CLIENT_PROPERTY_TABLE_COLUMN_NAME
Deprecated. 
When hideColumn(javax.swing.JTable, int) is called, we will call the code below to save the original column. You can get it from the client property if you need the information.
 table.putClientProperty(CLIENT_PROPERTY_TABLE_COLUMN_NAME + col.getHeaderValue(), col);
 

See Also:
Constant Field Values

CLIENT_PROPERTY_TABLE_COLUMN_INDEX

@Deprecated
public static final String CLIENT_PROPERTY_TABLE_COLUMN_INDEX
Deprecated. 
When hideColumn(javax.swing.JTable, int) is called, we will call the code below to save the original column. You can get it from the client property if you need the information.
 table.putClientProperty(CLIENT_PROPERTY_TABLE_COLUMN_INDEX + col.getModelIndex(), col);
 

See Also:
Constant Field Values

CLIENT_PROPERTY_TABLE_COLUMN_IDENTIFIER

public static final String CLIENT_PROPERTY_TABLE_COLUMN_IDENTIFIER
When hideColumn(javax.swing.JTable, int) is called, we will call the code below to save the original column. You can get it from the client property if you need the information.
 table.putClientProperty(CLIENT_PROPERTY_TABLE_COLUMN_IDENTIFIER + col.getIdentifier(), col);
 

See Also:
Constant Field Values

CLIENT_PROPERTY_HIDDEN_IDENTIFIER_LIST

public static final String CLIENT_PROPERTY_HIDDEN_IDENTIFIER_LIST
When hideColumn(javax.swing.JTable, int) or showColumn(javax.swing.JTable, String, int, int) is invoked, we will update the hidden identifier list so that you could locate the list of the hidden identifiers.

See Also:
Constant Field Values

CLIENT_PROPERTY_COLUMN_CHOOSER_DIALOG_STYLE

public static final String CLIENT_PROPERTY_COLUMN_CHOOSER_DIALOG_STYLE
Since 2.10.1, we use DualList in TableColumnChooserDialog. To change the behavior back, please set this client property for your table with Boolean.TRUE.

See Also:
Constant Field Values

CLIENT_PROPERTY_COLUMN_SORT_ORDER

public static final String CLIENT_PROPERTY_COLUMN_SORT_ORDER
You can set this client property for your table to SortableListModel.SORT_ASCENDING, SortableListModel.SORT_DESCENDING or SortableListModel.UNSORTED. The CheckBoxList in the TableColumnChooserDialog will sort the column according to the value you set.

Since:
3.3.6
See Also:
Constant Field Values

CLIENT_PROPERTY_TABLE_CHANGED

public static final String CLIENT_PROPERTY_TABLE_CHANGED
When grouping or ungrouping, JideTable.tableChanged(TableModelEvent) is called, we will call the code below to save the information that the table is changed. When showColumn(javax.swing.JTable, String, int, int) is called, we will reset the modelIndex in columnModel based on the identifiers.
 table.putClientProperty(CLIENT_PROPERTY_TABLE_CHANGED, true);
 

See Also:
Constant Field Values

CLIENT_PROPERTY_TABLE_COLUMN_WIDTH_RESET

public static final String CLIENT_PROPERTY_TABLE_COLUMN_WIDTH_RESET
By default, column width will not be reset when choosing "reset to default".

ColumnWidthTableModel will always be respected if there is one no matter if this client property is set or not. If there is no ColumnWidthTableModel in place and this property is set to Boolean.TRUE, the column width will be reset to 75.

Since:
3.4.2
See Also:
Constant Field Values
Constructor Detail

TableColumnChooser

@Deprecated
public TableColumnChooser()
Deprecated. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.

Method Detail

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class MouseAdapter

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class MouseAdapter

isKeepColumnOrder

@Deprecated
public boolean isKeepColumnOrder()
Deprecated. This method is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.

Returns:
the flag.

setKeepColumnOrder

@Deprecated
public void setKeepColumnOrder(boolean keepColumnOrder)
Deprecated. This method is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.

Parameters:
keepColumnOrder - the flag

reorderColumns

public static void reorderColumns(JTable table,
                                  int[] visibleModelIndices)
Reorder the columns according the visible column index array. The columns which indices are not appeared in the array will be hidden. The order in the array will determine the order of organized table.

Parameters:
table - the table to be reordered
visibleModelIndices - the model indices array

createColumnChooserMenuItems

@Deprecated
protected void createColumnChooserMenuItems(JPopupMenu popup,
                                                       JTableHeader header,
                                                       int[] fixedColumns,
                                                       int clickingColumn)
Deprecated. This method is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.

Parameters:
popup - the popup menu
header - the table header
fixedColumns - the fixed columns
clickingColumn - the clicking column

createColumnChooserMenuItems

@Deprecated
protected void createColumnChooserMenuItems(JPopupMenu popup,
                                                       JTableHeader header,
                                                       int[] fixedColumns,
                                                       int[] hiddenColumns,
                                                       int clickingColumn)
Deprecated. This method is not used anymore. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.

Parameters:
popup - the popup menu
header - the table header
fixedColumns - the fixed columns
hiddenColumns - the hidden columns
clickingColumn - the clicking column

getDisplayColumnName

protected String getDisplayColumnName(JTable table,
                                      int columnIndex)
Gets the display column name to be displayed on the popup menu.

Parameters:
table - the table
columnIndex - the column index as in table model.
Returns:
the display name for the column at the specified column index.

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

install

@Deprecated
public static TableColumnChooser install(JTable table)
Deprecated. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.

Parameters:
table - the table
Returns:
the instance of TableColumnChooser.

uninstall

@Deprecated
public static void uninstall(JTable table)
Deprecated. Using TableColumnChooser to add header popup menu is replaced with TableHeaderPopupMenuInstaller class which is more powerful and flexible. Please refer to the JavaDoc of TableHeaderPopupMenuInstaller for more information.

Parameters:
table - the table

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

getColumnIndex

public static int getColumnIndex(TableColumnModel model,
                                 int modelCol)
Gets the index of the column in the specified TableColumnModel.

Parameters:
model - table column model
modelCol - the column index in table model
Returns:
the index of the column in the specified TableColumnModel.

isVisibleColumn

public static boolean isVisibleColumn(JTable table,
                                      int modelIndex)
Checks if a column is visible.

Parameters:
table - the table
modelIndex - the column index in table model
Returns:
true if the column is visible. Otherwise false.

getVisibleColumns

public static Set<Integer> getVisibleColumns(JTable table)
Gets a Set of column indices that are visible.

It will invoke getVisibleColumns(javax.swing.JTable, boolean) with the second parameter as true by default.

Parameters:
table - the table
Returns:
Set of column indices that are visible.
See Also:
getVisibleColumns(javax.swing.JTable, boolean)

getVisibleColumns

public static Set<Integer> getVisibleColumns(JTable table,
                                             boolean considerTableScrollPane)
Gets a Set of column indices that are visible.

Parameters:
table - the table
considerTableScrollPane - the flag indicating if we should consider the other tables in the same TableScrollPane.
Returns:
Set of column indices that are visible.

getActualTable

public static JTable getActualTable(JTable table,
                                    int modelIndex)
Get actual table instance from the model index in table scroll pane scenario.

If the table is not in table scroll pane, we will just return the table itself.

Parameters:
table - whichever table existing in the table scroll pane
modelIndex - the model index
Returns:
the actual table instance where the column with the input model index resides.

getAllTables

public static JTable[] getAllTables(JTable table)
Get all table instances from any one table in table scroll pane scenario.

If the table is not in table scroll pane, we will just return the table itself.

Parameters:
table - whichever table existing in the table scroll pane
Returns:
all table instances resides in the table scroll pane.

getActualIndex

public static int getActualIndex(JTable table,
                                 int columnIndex)
Get actual index from the model index in table scroll pane scenario.

If the table is not in table scroll pane, we will just return the column index itself.

Parameters:
table - whichever table existing in the table scroll pane
columnIndex - the column index
Returns:
the visual column index in that table.

isVisibleColumn

public static boolean isVisibleColumn(TableColumnModel model,
                                      int modelCol)
Checks if a column is visible.

Parameters:
model - table column model
modelCol - the column index in table model
Returns:
true if the column is visible. Otherwise false.

getColumnIndex

public static int getColumnIndex(TableColumnModel model,
                                 TableColumn col)
Gets the view index of the column in the specified TableColumnModel.

Parameters:
model - table column model
col - the TableColumn instance
Returns:
the view index of the column in the specified TableColumnModel.

isVisibleColumn

public static boolean isVisibleColumn(TableColumnModel model,
                                      TableColumn col)
Checks if a column is visible.

Parameters:
model - table column model
col - the TableColumn
Returns:
true if the column is visible. Otherwise false.

showColumn

public static void showColumn(JTable table,
                              int modelIndex,
                              int viewIndex)
Shows the TableColumn at the specified column index. You should use this method only when you also use hideColumn(javax.swing.JTable, int) to hide the column.

Parameters:
table - the table
modelIndex - the column index in TableModel. This is the column that will be shown.
viewIndex - new column view index. This is optional. You can use -1. Otherwise the new column will be put at this view index.

showColumn

public static void showColumn(JTable table,
                              String columnIdentifier,
                              int modelIndex,
                              int newColumnIndex)
Shows the TableColumn with the specified name. You should use this method only when you also use hideColumn(javax.swing.JTable, int) to hide the column.

Parameters:
table - the table
columnIdentifier - if you use this parameter, we will try to locate the column based on this name. If not found, we will try to find the column based on modelIndex.
modelIndex - the column index in TableModel. This is the column that will be shown.
newColumnIndex - new column view index. This is optional. You can use -1. Otherwise the new column will be put at this view index.

hideColumn

public static void hideColumn(JTable table,
                              int modelIndex)
Hides the table column at the specified index. The good thing about this method than call directly to TableColumnModel's removeColumn is this method will save the TableColumn instance as client property so that later on showFrame will use saved client property to get TableColumn and put it back.

Parameters:
table - the table
modelIndex - the column index as in table model.

hasHiddenColumns

public static boolean hasHiddenColumns(JTable table)
Checks if the table has hidden columns.

Parameters:
table - the table.
Returns:
true if the table has hidden columns. Otherwise false.

getAllHiddenColumns

public static int[] getAllHiddenColumns(JTable table)
Gets all the hidden columns.

Parameters:
table - the table.
Returns:
all the hidden columns in this table. If the table is inside a TableScrollPane, it will return all the hidden columns in the TableScrollPane.

showAllColumns

public static void showAllColumns(JTable table)
Shows all columns that were hidden.

Parameters:
table - the table.

hideColumns

public static void hideColumns(JTable table,
                               int[] modelColumnIndexes)
Hides the columns at specified indices. Please note the column index is relative to the table model, not table column model.

Parameters:
table - the table
modelColumnIndexes - the columns to be hidden and the rest will be shown.

showColumns

public static void showColumns(JTable table,
                               int[] modelColumnIndexes)
Shows the columns at specified indices. Please note the column index is relative to the table model, not table column model.

Parameters:
table - the table
modelColumnIndexes - the columns to be shown and the rest will be hidden

resetColumnsToDefault

public static void resetColumnsToDefault(JTable table)
Reset the visible columns to all the columns in table model and clear all previous hiding actions. After reset, the order of the columns will be exactly the same as you create the original table model. No group, no hiding.

The method is expecting that columns in table.getColumnModel() will always exist in table.getModel()

Parameters:
table - the table to be reset

getTableColumnChooserButton

public static AbstractButton getTableColumnChooserButton(JTable table)
Gets the table column chooser button so that you can add it to the JScrollPane.UPPER_RIGHT_CORNER of a JScrollPane.

Parameters:
table - the table
Returns:
the button. User clicks on it will show a table column chooser dialog.

getTableColumnChooserButton

public static AbstractButton getTableColumnChooserButton(JTable table,
                                                         boolean[] hidableColumns)
Gets a button which will invoke a TableColumnChooserDialog to allow user show or hide columns. You can add this button to the corner of a scroll pane using the code below.

 JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
 scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, TableColumnChooser.getTableColumnChooserButton(table,
 ...);
 
Please make sure you have VERTICAL_SCROLLBAR_ALWAYS. Otherwise, the vertical scroll bar could be hidden then the button will be hidden too.

Parameters:
table - the table
hidableColumns - the array of boolean to indicate which column can be hidden.
Returns:
the button. User clicks on it will show a table column chooser dialog.

getTableColumnChooserButton

public static AbstractButton getTableColumnChooserButton(JTable table,
                                                         String[] descriptions)
Gets a button which will invoke a TableColumnChooserDialog to allow user show or hide columns. You can add this button to the corner of a scroll pane using the code below.

 JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
 scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, TableColumnChooser.getTableColumnChooserButton(table,
 ...);
 
Please make sure you have VERTICAL_SCROLLBAR_ALWAYS. Otherwise, the vertical scroll bar could be hidden then the button will be hidden too.

Parameters:
table - the table
descriptions - the descriptions for all columns as the order in the TableModel. It will appear in the column chooser dialog instead of the column name.
Returns:
the button. User clicks on it will show a table column chooser dialog.

getTableColumnChooserButton

public static AbstractButton getTableColumnChooserButton(JTable table,
                                                         boolean[] hidableColumns,
                                                         String[] descriptions)
Gets a button which will invoke a TableColumnChooserDialog to allow user show or hide columns. You can add this button to the corner of a scroll pane using the code below.

 JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
 scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, TableColumnChooser.getTableColumnChooserButton(table,
 ...);
 
Please make sure you have VERTICAL_SCROLLBAR_ALWAYS. Otherwise, the vertical scroll bar could be hidden then the button will be hidden too.

Parameters:
table - the table
hidableColumns - the array of boolean to indicate which column can be hidden.
descriptions - the descriptions for all columns as the order in the TableModel. It will appear in the column chooser dialog instead of the colum name.
Returns:
a button which will invoke a TableColumnChooserDialog to allow user show or hide columns.
See Also:
TableColumnChooserDialog

getTableColumnChooserButton

public static AbstractButton getTableColumnChooserButton(JTable table,
                                                         int[] fixedColumns,
                                                         String[] descriptions)
Gets a button which will invoke a TableColumnChooserDialog to allow user show or hide columns. You can add this button to the corner of a scroll pane using the code below.

 JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
 scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, TableColumnChooser.getTableColumnChooserButton(table,
 ...);
 
Please make sure you have VERTICAL_SCROLLBAR_ALWAYS. Otherwise, the vertical scroll bar could be hidden then the button will be hidden too.

Parameters:
table - the table
fixedColumns - the column indices that can not be hidden.
descriptions - the descriptions for all columns as the order in the TableModel. It will appear in the column chooser dialog instead of the column name.
Returns:
a button which will invoke a TableColumnChooserDialog to allow user show or hide columns.
See Also:
TableColumnChooserDialog

getTableColumnChooserButton

public static AbstractButton getTableColumnChooserButton(JTable table,
                                                         int[] fixedColumns,
                                                         int[] hiddenColumns,
                                                         String[] descriptions)
Gets a button which will invoke a TableColumnChooserDialog to allow user show or hide columns. You can add this button to the corner of a scroll pane using the code below.

 JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
 scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, TableColumnChooser.getTableColumnChooserButton(table,
 ...);
 
Please make sure you have VERTICAL_SCROLLBAR_ALWAYS. Otherwise, the vertical scroll bar could be hidden then the button will be hidden too.

Parameters:
table - the table
fixedColumns - the column indices that can not be hidden.
hiddenColumns - the column indices that should not be visible in the list.
descriptions - the descriptions for all columns as the order in the TableModel. It will appear in the column chooser dialog instead of the column name.
Returns:
a button which will invoke a TableColumnChooserDialog to allow user show or hide columns.
See Also:
TableColumnChooserDialog

getTableColumnChooserDialog

public static TableColumnChooserDialog getTableColumnChooserDialog(Frame parent,
                                                                   JTable table,
                                                                   boolean[] hidableColumns,
                                                                   String[] descriptions)
Gets the TableColumnChooserDialog for the table. You can get the dialog and decide how to display it. You can also use any of the TableColumnChooser.getTableColumnChooserButton methods to get a button which will invoke this dialog.

Parameters:
parent - the parent for the dialog.
table - the table
hidableColumns - the array of boolean to indicate which column can be hidden.
descriptions - the descriptions for all columns as the order in the TableModel. It will appear in the column chooser dialog instead of the column name.
Returns:
a TableColumnChooserDialog.

getTableColumnChooserDialog

public static TableColumnChooserDialog getTableColumnChooserDialog(Frame parent,
                                                                   JTable table,
                                                                   int[] fixedColumns,
                                                                   String[] descriptions)
Gets the TableColumnChooserDialog for the table. You can get the dialog and decide how to display it. You can also use any of the TableColumnChooser.getTableColumnChooserButton methods to get a button which will invoke this dialog.

Parameters:
parent - the parent for the dialog
table - the table
fixedColumns - the column indices that can not be hidden.
descriptions - the descriptions for all columns as the order in the TableModel. It will appear in the column chooser dialog instead of the column name.
Returns:
a TableColumnChooserDialog.

getTableColumnChooserDialog

public static TableColumnChooserDialog getTableColumnChooserDialog(Frame parent,
                                                                   JTable table,
                                                                   int[] fixedColumns,
                                                                   int[] hiddenColumns,
                                                                   String[] descriptions)
Gets the TableColumnChooserDialog for the table. You can get the dialog and decide how to display it. You can also use any of the TableColumnChooser.getTableColumnChooserButton methods to get a button which will invoke this dialog.

Parameters:
parent - the parent for the dialog
table - the table
fixedColumns - the column indices that can not be hidden.
hiddenColumns - the column indices that should not be visible in the list.
descriptions - the descriptions for all columns as the order in the TableModel. It will appear in the column chooser dialog instead of the column name.
Returns:
a TableColumnChooserDialog.

getTableColumnChooserDialog

public static TableColumnChooserDialog getTableColumnChooserDialog(Dialog parent,
                                                                   JTable table,
                                                                   boolean[] hidableColumns,
                                                                   String[] descriptions)
Gets the TableColumnChooserDialog for the table. You can get the dialog and decide how to display it. You can also use any of the TableColumnChooser.getTableColumnChooserButton methods to get a button which will invoke this dialog.

Parameters:
parent - the parent for the dialog
table - the table
hidableColumns - the columns that shouldn't be hidden if the corresponding boolean in the array is false.
descriptions - the descriptions for all columns as the order in the TableModel. It will appear in the column chooser dialog instead of the column name.
Returns:
a TableColumnChooserDialog.

getTableColumnChooserDialog

public static TableColumnChooserDialog getTableColumnChooserDialog(Dialog parent,
                                                                   JTable table,
                                                                   int[] fixedColumns,
                                                                   String[] descriptions)
Gets the TableColumnChooserDialog for the table. You can get the dialog and decide how to display it. You can also use any of the TableColumnChooser.getTableColumnChooserButton methods to get a button which will invoke this dialog.

Parameters:
parent - the parent for the dialog
table - the table
fixedColumns - the column indices that can not be hidden.
descriptions - the descriptions for all columns as the order in the TableModel. It will appear in the column chooser dialog instead of the column name.
Returns:
a TableColumnChooserDialog.

getTableColumnChooserDialog

public static TableColumnChooserDialog getTableColumnChooserDialog(Dialog parent,
                                                                   JTable table,
                                                                   int[] fixedColumns,
                                                                   int[] hiddenColumns,
                                                                   String[] descriptions)
Gets the TableColumnChooserDialog for the table. You can get the dialog and decide how to display it. You can also use any of the TableColumnChooser.getTableColumnChooserButton methods to get a button which will invoke this dialog.

Parameters:
parent - the parent for the dialog
table - the table
fixedColumns - the column indices that can not be hidden.
hiddenColumns - the column indices that should not be visible in the list.
descriptions - the descriptions for all columns as the order in the TableModel. It will appear in the column chooser dialog instead of the column name.
Returns:
a TableColumnChooserDialog.

JIDE 3.5.15