dyntable
Class JFeatureTable

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JTable
                          |
                          +--dyntable.JFeatureTable
All Implemented Interfaces:
javax.accessibility.Accessible, javax.swing.event.CellEditorListener, java.util.EventListener, java.awt.image.ImageObserver, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener

public class JFeatureTable
extends javax.swing.JTable

$Id: MultiSpanCellTable.java,v 1.0 2005/09/25 jDynTable@gmx.de $
The JFeatureTable is an extension of Java's JTable. It has an extended functionality compared to JTable and supports as additional functionality the combination (and splitting) of table cells, the easy resizing of columns and rows and cares for the popup menu which enables deleting rows, inserting rows, ... Especially the method getCellRect is very important for the split and cobine feature and defines the size and position of each cell. Therefor some methods of JTable are also overwritten in this class.

Version:
$Revision: 1.0 $
Author:
$Author: jdyntable@gmx.de $
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
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
JFeatureTable()
          Constructs a new MultiSpanCellTable.
JFeatureTable(JDynTable tblPanel)
          Constructs a new MultiSpanCellTable with a given TableModel.
JFeatureTable(javax.swing.table.TableModel model)
          Constructs a new MultiSpanCellTable with a given TableModel.
 
Method Summary
 void changeSelection(int row, int column, boolean toggle, boolean extend)
          The changeSelection method is overwritten to exchange the cursor when it is when it is being moved over a line.
 int columnAtPoint(java.awt.Point point)
          Returns the index of the column at the given Point.
 void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
           
 javax.swing.table.TableCellEditor getCellEditor(int row, int column)
          This method is overwritte to provide the correct cell editor in case of multi span cells
 java.awt.Rectangle getCellRect(int row, int column, boolean includeSpacing)
           
 java.lang.Object getValueAt(int row, int column)
          This method is overwritte to provide the correct cell editor in case of multi span cells
 void processMouseEvent(java.awt.event.MouseEvent event)
          Method overridden for managing context menu
 int rowAtPoint(java.awt.Point point)
          Returns the index of row at the given Point.
 void setResizable(boolean row, boolean column)
          The setResizable method is used to enable or disable the resize feature.
 void valueChanged(javax.swing.event.ListSelectionEvent e)
           
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, clearSelection, columnAdded, columnMarginChanged, columnMoved, columnRemoved, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnsFromModel, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellRenderer, 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, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, prepareEditor, prepareRenderer, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, 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, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, 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, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JFeatureTable

public JFeatureTable()
Constructs a new MultiSpanCellTable.


JFeatureTable

public JFeatureTable(javax.swing.table.TableModel model)
Constructs a new MultiSpanCellTable with a given TableModel.


JFeatureTable

public JFeatureTable(JDynTable tblPanel)
Constructs a new MultiSpanCellTable with a given TableModel.

Method Detail

getCellRect

public java.awt.Rectangle getCellRect(int row,
                                      int column,
                                      boolean includeSpacing)
Overrides:
getCellRect in class javax.swing.JTable
See Also:
JTable.getCellRect(int, int, boolean)

rowAtPoint

public int rowAtPoint(java.awt.Point point)
Returns the index of row at the given Point. The index returned can be used to retrieve the actual row. The Point x and y values start at 0 and represent a location on the screen in pixels.

Overrides:
rowAtPoint in class javax.swing.JTable
Returns:
int the index of the column and row. The first column has index 0.

columnAtPoint

public int columnAtPoint(java.awt.Point point)
Returns the index of the column at the given Point. The index returned can be used to retrieve the column. The Point x and y values start at 0 and represent a location on the screen in pixels.

Overrides:
columnAtPoint in class javax.swing.JTable
Returns:
int the index of the column. The first column has index 0.

columnSelectionChanged

public void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
Specified by:
columnSelectionChanged in interface javax.swing.event.TableColumnModelListener
Overrides:
columnSelectionChanged in class javax.swing.JTable
See Also:
TableColumnModelListener.columnSelectionChanged(javax.swing.event.ListSelectionEvent)

getCellEditor

public javax.swing.table.TableCellEditor getCellEditor(int row,
                                                       int column)
This method is overwritte to provide the correct cell editor in case of multi span cells

Overrides:
getCellEditor in class javax.swing.JTable
See Also:
JTable.getCellEditor(int, int)

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
This method is overwritte to provide the correct cell editor in case of multi span cells

Overrides:
getValueAt in class javax.swing.JTable
See Also:
JTable.getCellEditor(int, int)

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent e)
Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener
Overrides:
valueChanged in class javax.swing.JTable
See Also:
ListSelectionListener.valueChanged(javax.swing.event.ListSelectionEvent)

processMouseEvent

public void processMouseEvent(java.awt.event.MouseEvent event)
Method overridden for managing context menu

Overrides:
processMouseEvent in class java.awt.Component
See Also:
java.awt.Component#processMouseEvent(java.awt.event.MouseEvent e)

setResizable

public void setResizable(boolean row,
                         boolean column)
The setResizable method is used to enable or disable the resize feature.

Parameters:
row - true if row resizing is to be enabled
column - true if column resizing is to be enabled

changeSelection

public void changeSelection(int row,
                            int column,
                            boolean toggle,
                            boolean extend)
The changeSelection method is overwritten to exchange the cursor when it is when it is being moved over a line.

Overrides:
changeSelection in class javax.swing.JTable
Parameters:
toggle - see description above
extend - if true, extend the current selection
See Also:
JTable.changeSelection(int, int, boolean, boolean)