HOME

com.ultraswing
Class CTable

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JTable
                          |
                          +--com.ultraswing.CTable
All Implemented Interfaces:
Accessible, CellEditorListener, EventListener, ImageObserver, ListSelectionListener, MenuContainer, Scrollable, Serializable, TableColumnModelListener, TableModelListener

public class CTable
extends JTable

An extension of JTable which adds the following functionality.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CTable()
          Constructs a default CTable that is initialized with a default data model, a default column model, and a default selection model.
CTable(int rows, int cols)
          Constructs a CTable with rows and cols of empty cells using DefaultTableModel.
CTable(Object[][] rowData, Object[] columnNames)
          Constructs a CTable to display the values in the two dimensional array, rowData, with column names, columnNames.
CTable(SortableTableModel model)
          Constructs a CTable that is initialized with model as the data model, a default column model, and a default selection model.
CTable(SortableTableModel dm, TableColumnModel cm)
          Constructs a CTable that is initialized with dm as the data model, cm as the column model, and a default selection model.
CTable(SortableTableModel dm, TableColumnModel cm, ListSelectionModel sm)
          Constructs a CTable that is initialized with dm as the data model, cm as the column model, and sm as the selection model.
CTable(String csvFileName, boolean hasHeadings)
          Constructs a CTable that is initialized with the passed CSV file
CTable(URL csvFileURL, boolean hasHeadings)
          Constructs a CTable that is initialized with the passed CSV file
CTable(Vector rowData, Vector columnNames)
          Constructs a CTable to display the values in the Vector of Vectors, rowData, with column names, columnNames.
 
Method Summary
protected  void configureEnclosingScrollPane()
           
 void disableAlternate()
          Disables alternate row/colum color
 TableCellRenderer getCellRenderer(int row, int column)
           
 CTableRowHeader getCTableRowHeader()
          Return Table row header object.
 int[] getHiddenColumns()
          Returns the hidden column indice
 int getSortedColumnIndex()
          Returns the column index of sorted column
 boolean isCellEditable(int row, int column)
          Determines whether the cell is editable
 boolean isEditable()
          Determines whether the whole table is editable
 boolean isSortedColumnAscending()
          Determines whether the sorted column is ascending
 boolean isSortingEnabled()
          Determines whether column sorting is enabled
 void removeColumns(int[] columns)
          Removes passed columns from table
 void removeHeader(int mode)
          Removes table headers Note: This method take effect only when this table is already visible.
 void resetCellColor(int row, int column)
          Undo the setCellColor
 void resetColumnColor(int column)
          Undo resetRowColor
 void resetRowColor(int row)
          Undo setRowColor
 void setAlternate(Color c1, Color c2, boolean isRowAlternate)
          Alternates colors for rows or columns.
 void setCellColor(int row, int column, Color color)
          This method takes precedence over setColumnColor, setRowColor, and setAlternate methods
 void setColumnColor(int column, Color c)
          This method takes precedence over setAlternate method
 void setEditable(boolean b)
          Sets the specified boolean to indicate whether or not this whole table should be editable.
 void setRowColor(int row, Color c)
          This method takes precedence over setColumnColor and setAlternate methods
 void setRowHeaderEnabled(boolean b)
          Enables or disables row header
 void setRowHeaderValues(List list)
          Sets row header values
 void setRowHeight(int row, int rowHeight)
          Sets row height
 void setSortingEnabled(boolean b)
          Controls whether column sorting is enabled or not
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditingRow, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getValueAt, initializeLocalVars, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setValueAt, sizeColumnsToFit, sizeColumnsToFit, tableChanged, unconfigureEnclosingScrollPane, updateUI, valueChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CTable

public CTable()
Constructs a default CTable that is initialized with a default data model, a default column model, and a default selection model.


CTable

public CTable(int rows,
              int cols)
Constructs a CTable with rows and cols of empty cells using DefaultTableModel. The columns will have names of the form "A", "B", "C", etc.

Parameters:
rows - the number of rows the table holds
cols - the number of columns the table holds

CTable

public CTable(Object[][] rowData,
              Object[] columnNames)
Constructs a CTable to display the values in the two dimensional array, rowData, with column names, columnNames. rowData is an array of rows, so the value of the cell at row 1, column 5 can be obtained with the following code:

 rowData[1][5]; 

All rows must be of the same length as columnNames.

Parameters:
rowData - the data for the new table
columnNames - names of each column

CTable

public CTable(Vector rowData,
              Vector columnNames)
Constructs a CTable to display the values in the Vector of Vectors, rowData, with column names, columnNames. The Vectors contained in rowData should contain the values for that row. In other words, the value of the cell at row 1, column 5 can be obtained with the following code:

((Vector)rowData.elementAt(1)).elementAt(5);

Each row must contain a value for each column or an exception will be raised.

Parameters:
rowData - the data for the new table
columnNames - names of each column

CTable

public CTable(SortableTableModel model)
Constructs a CTable that is initialized with model as the data model, a default column model, and a default selection model.

Parameters:
model - the data model for the table

CTable

public CTable(SortableTableModel dm,
              TableColumnModel cm)
Constructs a CTable that is initialized with dm as the data model, cm as the column model, and a default selection model.

Parameters:
dm - the data model for the table
cm - the column model for the table

CTable

public CTable(SortableTableModel dm,
              TableColumnModel cm,
              ListSelectionModel sm)
Constructs a CTable that is initialized with dm as the data model, cm as the column model, and sm as the selection model. If any of the parameters are null this method will initialize the table with the corresponding default model. The autoCreateColumnsFromModel flag is set to false if cm is non-null, otherwise it is set to true and the column model is populated with suitable TableColumns for the columns in dm.

Parameters:
dm - the data model for the table
cm - the column model for the table
sm - the row selection model for the table

CTable

public CTable(URL csvFileURL,
              boolean hasHeadings)
       throws IOException
Constructs a CTable that is initialized with the passed CSV file

Parameters:
csvFileURL - the URL of CSV file
hasHeadings - whehter the CSV has headings or not

CTable

public CTable(String csvFileName,
              boolean hasHeadings)
       throws IOException
Constructs a CTable that is initialized with the passed CSV file

Parameters:
csvFileName - the file name of CSV file
hasHeadings - whehter the CSV has headings or not
Method Detail

setRowHeaderValues

public void setRowHeaderValues(List list)
Sets row header values

Parameters:
list - values of row header. Each element in the list can be a String object, Component object, or other objects.

setCellColor

public void setCellColor(int row,
                         int column,
                         Color color)
This method takes precedence over setColumnColor, setRowColor, and setAlternate methods


resetCellColor

public void resetCellColor(int row,
                           int column)
Undo the setCellColor

See Also:
setCellColor(int, int, java.awt.Color)

setRowColor

public void setRowColor(int row,
                        Color c)
This method takes precedence over setColumnColor and setAlternate methods


resetRowColor

public void resetRowColor(int row)
Undo setRowColor

See Also:
setRowColor(int, java.awt.Color)

setColumnColor

public void setColumnColor(int column,
                           Color c)
This method takes precedence over setAlternate method


resetColumnColor

public void resetColumnColor(int column)
Undo resetRowColor

See Also:
setColumnColor(int, java.awt.Color)

setAlternate

public void setAlternate(Color c1,
                         Color c2,
                         boolean isRowAlternate)
Alternates colors for rows or columns.
Note: It 's NOT possbile to have both alternative rows and columns at the same time

Parameters:
c1 - The color for row/column where row/column number is even
c2 - The color for row/column where row/column number is odd
isRowAlternate - Alternates colors on rows (true) or columns (false)

disableAlternate

public void disableAlternate()
Disables alternate row/colum color


getCellRenderer

public TableCellRenderer getCellRenderer(int row,
                                         int column)
Overrides:
getCellRenderer in class JTable

removeColumns

public void removeColumns(int[] columns)
Removes passed columns from table


getHiddenColumns

public int[] getHiddenColumns()
Returns the hidden column indice


setSortingEnabled

public void setSortingEnabled(boolean b)
Controls whether column sorting is enabled or not


isSortingEnabled

public boolean isSortingEnabled()
Determines whether column sorting is enabled


getSortedColumnIndex

public int getSortedColumnIndex()
Returns the column index of sorted column


isSortedColumnAscending

public boolean isSortedColumnAscending()
Determines whether the sorted column is ascending


removeHeader

public void removeHeader(int mode)
Removes table headers Note: This method take effect only when this table is already visible. For example, called after setVisible(true);

Parameters:
mode - 0: all headers; 1: column header; 2: row header

setEditable

public void setEditable(boolean b)
Sets the specified boolean to indicate whether or not this whole table should be editable.

Parameters:
b - a boolean value, true if the tree is editable

isEditable

public boolean isEditable()
Determines whether the whole table is editable


isCellEditable

public boolean isCellEditable(int row,
                              int column)
Determines whether the cell is editable

Overrides:
isCellEditable in class JTable

setRowHeaderEnabled

public void setRowHeaderEnabled(boolean b)
Enables or disables row header


getCTableRowHeader

public CTableRowHeader getCTableRowHeader()
Return Table row header object. Or null if table row header is not enabled or table is not contained in a JScrollPane

See Also:
setRowHeaderEnabled(boolean)

setRowHeight

public void setRowHeight(int row,
                         int rowHeight)
Sets row height

Overrides:
setRowHeight in class JTable
Parameters:
row - row index
rowHeight - row height, in pixels

configureEnclosingScrollPane

protected void configureEnclosingScrollPane()
Overrides:
configureEnclosingScrollPane in class JTable

HOME

Copyright © 2002 iReasoning Networks. All Rights Reserved.