jwo.utils.gui
Class EditableHeader

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.table.JTableHeader
                  extended byjwo.utils.gui.EditableHeader
All Implemented Interfaces:
Accessible, CellEditorListener, EventListener, ImageObserver, MenuContainer, Serializable, TableColumnModelListener

public class EditableHeader
extends JTableHeader
implements CellEditorListener

A table header that can be edited by double clicking on the header entry.

Version:
2.1, 19th August, 2004.
Author:
Based on the code provided by Nobuo Tamemasa, modified by Jo Wood.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.table.JTableHeader
JTableHeader.AccessibleJTableHeader
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.table.JTableHeader
columnModel, draggedColumn, draggedDistance, reorderingAllowed, resizingAllowed, resizingColumn, table, updateTableInRealTime
 
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
EditableHeader(TableColumnModel columnModel, CellEditorListener editorListener)
          Creates a new editable header based on the given column model.
 
Method Summary
 boolean editCellAt(int index, EventObject e)
          Allows the cell at the given index to be edited.
 void editingCanceled(ChangeEvent e)
          Removes editor from the header.
 void editingStopped(ChangeEvent e)
          Called whenever editing has finished.
 TableCellEditor getCellEditor()
          Reports the cell editor used to edit header cells.
 TableCellEditor getCellEditor(int index)
          Reports the cell editor used to edit the given header cell.
 int getEditingColumn()
          Reports the column to be edited.
 Component getEditorComponent()
          Reports the GUI component used to represent the editable cell.
 boolean isCellEditable(int index)
          Reports whether the given header cell is editable.
 boolean isEditing()
          Reports whether or not there is a cell being edited
 Component prepareEditor(TableCellEditor editor, int index)
          Prepares the header at the given location for editing.
 void removeEditor()
          Removes the cell editor from the header.
 void setCellEditor(TableCellEditor newEditor)
          Sets the cell editor used to edit the header cells.
 void setEditingColumn(int column)
          Sets the column to be edited.
 void updateUI()
          Notification from the UIManager that the look and feel (L&F) has changed.
 
Methods inherited from class javax.swing.table.JTableHeader
columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, createDefaultColumnModel, createDefaultRenderer, getAccessibleContext, getColumnModel, getDefaultRenderer, getDraggedColumn, getDraggedDistance, getHeaderRect, getReorderingAllowed, getResizingAllowed, getResizingColumn, getTable, getToolTipText, getUI, getUIClassID, getUpdateTableInRealTime, initializeLocalVars, paramString, resizeAndRepaint, setColumnModel, setDefaultRenderer, setDraggedColumn, setDraggedDistance, setReorderingAllowed, setResizingAllowed, setResizingColumn, setTable, setUI, setUpdateTableInRealTime
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, 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, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, 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, doLayout, 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

EditableHeader

public EditableHeader(TableColumnModel columnModel,
                      CellEditorListener editorListener)
Creates a new editable header based on the given column model.

Parameters:
columnModel - Table column model uponwhich to base table header.
editorListener - Class to be informed if a header cell has been edited.
Method Detail

updateUI

public void updateUI()
Notification from the UIManager that the look and feel (L&F) has changed. Replaces the current UI object with the latest version from the UIManager.


editCellAt

public boolean editCellAt(int index,
                          EventObject e)
Allows the cell at the given index to be edited.

Parameters:
index - Index of header cell to edit.
e - GUI event that initiated the editing.
Returns:
True if edited.

isCellEditable

public boolean isCellEditable(int index)
Reports whether the given header cell is editable.

Parameters:
index - Index of cell to query.
Returns:
True if given cell is editable.

getCellEditor

public TableCellEditor getCellEditor(int index)
Reports the cell editor used to edit the given header cell.

Parameters:
index - Index of header cell from which to retrieve editor.
Returns:
Editor of the given cell.

getCellEditor

public TableCellEditor getCellEditor()
Reports the cell editor used to edit header cells.

Returns:
Editor used to edit header.

setCellEditor

public void setCellEditor(TableCellEditor newEditor)
Sets the cell editor used to edit the header cells.

Parameters:
newEditor - Editor to associate with the header.

prepareEditor

public Component prepareEditor(TableCellEditor editor,
                               int index)
Prepares the header at the given location for editing.

Parameters:
editor - Editor to associate with the header cell.
index - Index of header cell to edit.

getEditorComponent

public Component getEditorComponent()
Reports the GUI component used to represent the editable cell.

Returns:
Editor component.

setEditingColumn

public void setEditingColumn(int column)
Sets the column to be edited.

Parameters:
column - Column to edit.

getEditingColumn

public int getEditingColumn()
Reports the column to be edited.

Returns:
Column to edit.

removeEditor

public void removeEditor()
Removes the cell editor from the header.


isEditing

public boolean isEditing()
Reports whether or not there is a cell being edited

Returns:
True if a cell is being edited.

editingStopped

public void editingStopped(ChangeEvent e)
Called whenever editing has finished.

Specified by:
editingStopped in interface CellEditorListener
Parameters:
e - Event assoicated with finishing of editing.

editingCanceled

public void editingCanceled(ChangeEvent e)
Removes editor from the header.

Specified by:
editingCanceled in interface CellEditorListener
Parameters:
e - Event that prompted cancellation of editing.


Copyright Jo Wood, 1996-2004, last modified, 3rd September, 2004