Holger's
Java API

com.antelmann.util.table
Class JFilteredTableComponent

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.antelmann.util.table.JFilteredTableComponent
All Implemented Interfaces:
ListRetriever<TableRow>, ValueRetriever<TableRow>, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
JPopMessageTable

public class JFilteredTableComponent
extends JComponent
implements ListRetriever<TableRow>, ValueRetriever<TableRow>

a component that filters and sorts a given TableModel. This component uses a BorderLayout that contains a JScrollPane with a JTable in its center and uses a JTableFilterTextField at BorderLayout.NORTH as well as a status statusLabel at BorderLayout.SOUTH. In addition, the embedded JTable is also generically sortable, i.e. the given model is embedded into a FilteredTableModel which is then embedded into a SortableTableModel, which is used by the JTable.

Since:
6. Januar 2007, 22:53
Author:
Holger Antelmann
See Also:
JTableFilterTextField, Serialized Form

Nested Class Summary
 
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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
JFilteredTableComponent(TableModel model)
           
JFilteredTableComponent(TableModel model, Integer... columnsToCheck)
           
JFilteredTableComponent(TableModel model, SimpleTableRowFilter filter)
           
JFilteredTableComponent(TableModel model, SimpleTableRowFilter filter, boolean immediateSearch)
           
 
Method Summary
 FilteredTableModel getFilteredTableModel()
          this model is embedded by the SortableTableModel and embeds the original model
 JTableFilterTextField getFilterField()
          allows also access to the filter in use
 int getOriginalRowFor(int row)
          returns the corresponding row of the original TableModel for the given row in the model of the table (a SortableTableModel embedding a FilteredTableModel).
 List<TableRow> getRelevantList()
          returns the currently selected rows
 String getRelevantListDescription()
           
 TableRow getRelevantValue()
          returns the relevant value for this instance at the time of calling
 int getRowPosition(int originalRow)
          returns the corresponding row of the currently visible view given the row of the original model; may return a negative number if the row is not currently visible due to filtering.
 JScrollPane getScrollPane()
           
 SortableTableModel getSortableTableModel()
          this model is the model of the table; it embeds the FilteredTableModel
 JLabel getStatusLabel()
           
 JTable getTable()
          returns the JTable in use for customization; the table uses a SortableTableModel
 TableModel getTableModel()
          returns the original model given
 void replaceFilterActionListener(ActionListener al)
          convenience method to alter the behavior of the filter field that is defined in this context
 void setImmediateUpdate(boolean flag)
          shortcut to the corresponding method in the embedded JTableFilterTextField
protected  void updateStatusLabelText(int selectedRows, int totalRows)
          allows for a subclass to override how the status label is written (so that additional information from other filtering criteria may be written into the label as well).
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, 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, updateUI
 
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

JFilteredTableComponent

public JFilteredTableComponent(TableModel model)

JFilteredTableComponent

public JFilteredTableComponent(TableModel model,
                               Integer... columnsToCheck)

JFilteredTableComponent

public JFilteredTableComponent(TableModel model,
                               SimpleTableRowFilter filter)

JFilteredTableComponent

public JFilteredTableComponent(TableModel model,
                               SimpleTableRowFilter filter,
                               boolean immediateSearch)
Method Detail

updateStatusLabelText

protected void updateStatusLabelText(int selectedRows,
                                     int totalRows)
allows for a subclass to override how the status label is written (so that additional information from other filtering criteria may be written into the label as well).


getOriginalRowFor

public int getOriginalRowFor(int row)
returns the corresponding row of the original TableModel for the given row in the model of the table (a SortableTableModel embedding a FilteredTableModel).


getRowPosition

public int getRowPosition(int originalRow)
returns the corresponding row of the currently visible view given the row of the original model; may return a negative number if the row is not currently visible due to filtering.


getFilteredTableModel

public FilteredTableModel getFilteredTableModel()
this model is embedded by the SortableTableModel and embeds the original model


getSortableTableModel

public SortableTableModel getSortableTableModel()
this model is the model of the table; it embeds the FilteredTableModel


getTableModel

public TableModel getTableModel()
returns the original model given


getTable

public JTable getTable()
returns the JTable in use for customization; the table uses a SortableTableModel


getScrollPane

public JScrollPane getScrollPane()

getFilterField

public JTableFilterTextField getFilterField()
allows also access to the filter in use


replaceFilterActionListener

public void replaceFilterActionListener(ActionListener al)
convenience method to alter the behavior of the filter field that is defined in this context

See Also:
getFilterField()

getStatusLabel

public JLabel getStatusLabel()

setImmediateUpdate

public void setImmediateUpdate(boolean flag)
shortcut to the corresponding method in the embedded JTableFilterTextField


getRelevantValue

public TableRow getRelevantValue()
                          throws IOException
Description copied from interface: ValueRetriever
returns the relevant value for this instance at the time of calling

Specified by:
getRelevantValue in interface ValueRetriever<TableRow>
Throws:
IOException - if any resource to fulfill the request is not accessible

getRelevantList

public List<TableRow> getRelevantList()
                               throws IOException
returns the currently selected rows

Specified by:
getRelevantList in interface ListRetriever<TableRow>
Throws:
IOException

getRelevantListDescription

public String getRelevantListDescription()
Specified by:
getRelevantListDescription in interface ListRetriever<TableRow>


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads