jwo.utils.gui
Class EditableHeader

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

public class EditableHeader
extends JTableHeader
implements CellEditorListener

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

Version:
2.3, 4th October, 2007.
Author:
Based on the code provided by Nobuo Tamemasa, modified by Jo Wood.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.table.JTableHeader
JTableHeader.AccessibleJTableHeader
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces 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, 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, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, 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, doLayout, 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

EditableHeader

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

Parameters:
columnModel - Table column model upon which 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.

Overrides:
updateUI in class JTableHeader

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.
Returns:
Table component provided by editor.

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 associated 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-2009, last modified, 17th April, 2009