net.wotonomy.ui.swing.components
Class PropertyEditorTable

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTable
                  extended by net.wotonomy.ui.swing.components.PropertyEditorTable
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.CellEditorListener, javax.swing.event.ListSelectionListener, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener, javax.swing.Scrollable

public class PropertyEditorTable
extends javax.swing.JTable

PropertyEditorTable is a table designed to display and edit the properties of an object. Because JTable assumes all cells in a column display the same data type, we have to subclass to determine the class based on the cell contents.

Version:
$Revision: 904 $
Author:
michael@mpowers.net, $Author: cgruber $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTable
javax.swing.JTable.AccessibleJTable, javax.swing.JTable.PrintMode
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
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
PropertyEditorTable()
          Constructs a default JTable which is initialized with a default data model, a default column model, and a default selection model.
PropertyEditorTable(int numRows, int numColumns)
          Constructs a JTable with numRows and numColumns of empty cells using the DefaultTableModel.
PropertyEditorTable(java.lang.Object[][] rowData, java.lang.Object[] columnNames)
          Constructs a JTable to display the values in the two dimensional array, rowData, with column names, columnNames.
PropertyEditorTable(javax.swing.table.TableModel dm)
          Constructs a JTable which is initialized with dm as the data model, a default column model, and a default selection model.
PropertyEditorTable(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm)
          Constructs a JTable which is initialized with dm as the data model, cm as the column model, and a default selection model.
PropertyEditorTable(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm, javax.swing.ListSelectionModel sm)
          Constructs a JTable which is initialized with dm as the data model, cm as the column model, and sm as the selection model.
PropertyEditorTable(java.util.Vector rowData, java.util.Vector columnNames)
          Constructs a JTable to display the values in the Vector of Vectors, rowData, with column names, columnNames.
 
Method Summary
protected  void createDefaultEditors()
           
protected  void createDefaultRenderers()
           
 java.lang.Class getCellClass(int row, int column)
          Returns the type of the cell at the specified view position.
 javax.swing.table.TableCellEditor getCellEditor(int row, int column)
          Return an appropriate editor for the cell specified by this this row and column.
 javax.swing.table.TableCellRenderer getCellRenderer(int row, int column)
          Return an appropriate renderer for the cell specified by this this row and column.
 java.lang.Class getColumnClass(int column)
          Returns the type of the column at the specified view position.
protected  java.lang.String getFontDescription(java.awt.Font f)
           
 void methodInvoked(java.lang.Object anObject, java.lang.reflect.Method aMethod, java.lang.Object aResult)
          Called by the method cell editor when a method is invoked.
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellRect, getCellSelectionEnabled, getColumn, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditingRow, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, 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, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, 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, 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, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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

PropertyEditorTable

public PropertyEditorTable()
Constructs a default JTable which is initialized with a default data model, a default column model, and a default selection model.

See Also:
JTable.createDefaultDataModel(), JTable.createDefaultColumnModel(), JTable.createDefaultSelectionModel()

PropertyEditorTable

public PropertyEditorTable(javax.swing.table.TableModel dm)
Constructs a JTable which is initialized with dm as the data model, a default column model, and a default selection model.

Parameters:
dm - The data model for the table
See Also:
JTable.createDefaultColumnModel(), JTable.createDefaultSelectionModel()

PropertyEditorTable

public PropertyEditorTable(javax.swing.table.TableModel dm,
                           javax.swing.table.TableColumnModel cm)
Constructs a JTable which 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
See Also:
JTable.createDefaultSelectionModel()

PropertyEditorTable

public PropertyEditorTable(javax.swing.table.TableModel dm,
                           javax.swing.table.TableColumnModel cm,
                           javax.swing.ListSelectionModel sm)
Constructs a JTable which 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
See Also:
JTable.createDefaultDataModel(), JTable.createDefaultColumnModel(), JTable.createDefaultSelectionModel()

PropertyEditorTable

public PropertyEditorTable(int numRows,
                           int numColumns)
Constructs a JTable with numRows and numColumns of empty cells using the DefaultTableModel. The columns will have names of the form "A", "B", "C", etc.

Parameters:
numRows - The number of rows the table holds
numColumns - The number of columns the table holds

PropertyEditorTable

public PropertyEditorTable(java.util.Vector rowData,
                           java.util.Vector columnNames)
Constructs a JTable 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);

All rows must be of the same length as columnNames.

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

PropertyEditorTable

public PropertyEditorTable(java.lang.Object[][] rowData,
                           java.lang.Object[] columnNames)
Constructs a JTable 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
Method Detail

getColumnClass

public java.lang.Class getColumnClass(int column)
Returns the type of the column at the specified view position.

Overrides:
getColumnClass in class javax.swing.JTable
Returns:
the type of the column at position column in the view where the first column is column 0. Modified mln: now a wrapper for getCellClass()

getCellClass

public java.lang.Class getCellClass(int row,
                                    int column)
Returns the type of the cell at the specified view position.

Returns:
the type of the cell at position row, column in the view where the first column is column 0. Modified mln: new methods

getCellRenderer

public javax.swing.table.TableCellRenderer getCellRenderer(int row,
                                                           int column)
Return an appropriate renderer for the cell specified by this this row and column. If the TableColumn for this column has a non-null renderer, return that. If not, find the class of the data in this column (using getColumnClass()) and return the default renderer for this type of data.

Overrides:
getCellRenderer in class javax.swing.JTable
Parameters:
row - the row of the cell to render, where 0 is the first
column - the column of the cell to render, where 0 is the first Modified mln: calls getCellClass if there's no column model

getCellEditor

public javax.swing.table.TableCellEditor getCellEditor(int row,
                                                       int column)
Return an appropriate editor for the cell specified by this this row and column. If the TableColumn for this column has a non-null editor, return that. If not, find the class of the data in this column (using getColumnClass()) and return the default editor for this type of data.

Overrides:
getCellEditor in class javax.swing.JTable
Parameters:
row - the row of the cell to edit, where 0 is the first
column - the column of the cell to edit, where 0 is the first Modified mp: calls getCellClass if there's no column model

createDefaultRenderers

protected void createDefaultRenderers()
Overrides:
createDefaultRenderers in class javax.swing.JTable

getFontDescription

protected java.lang.String getFontDescription(java.awt.Font f)

createDefaultEditors

protected void createDefaultEditors()
Overrides:
createDefaultEditors in class javax.swing.JTable

methodInvoked

public void methodInvoked(java.lang.Object anObject,
                          java.lang.reflect.Method aMethod,
                          java.lang.Object aResult)
Called by the method cell editor when a method is invoked.

Parameters:
anObject - The object upon which the method was invoked.
aMethod - The method that was invoked.
aResult - The result of the method invocation; may be null.


Copyright © 2006 null. All Rights Reserved.