org.formaria.awt
Class Table

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.ScrollPane
              extended by org.formaria.awt.ScrollPane
                  extended by org.formaria.awt.Table
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, RowSelector, HashCode, ModelHolder, StyleComponent

public class Table
extends ScrollPane
implements ModelHolder, java.awt.ItemSelectable, StyleComponent, HashCode, RowSelector

Provides a simple read-only tables/grid component.

Copyright (c) Formaria Ltd.,
License: see license.txt $Revision: 2.7 $

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.ScrollPane
java.awt.ScrollPane.AccessibleAWTScrollPane
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class java.awt.ScrollPane
SCROLLBARS_ALWAYS, SCROLLBARS_AS_NEEDED, SCROLLBARS_NEVER
 
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
Table()
          Create a new table
 
Method Summary
 void addItemListener(java.awt.event.ItemListener l)
          Adds the specified item listener to receive item events from this list.
 void addMouseListener(java.awt.event.MouseListener l)
          Add a mouse listener
 void addNotify()
          Creates the scroll pane's peer and sizes the child element.
 void checkSize()
          Recalculate and check the size of the content
 void first()
          Move to the first row
 long getComponentHashCode()
          Get the hash code to be used by the event handler for this component
 java.awt.Container getComponentPanel()
          Create a panel for components
 java.lang.String getContent()
          Set the model's name
 java.lang.String getFieldValue(int fieldIdx)
          Gets a field value as a string from the currently selected row
 java.lang.String getFieldValue(int rowIdx, int fieldIdx)
          Gets a field value as a string from the specified row
 DataModel getModel()
          Get the underlying model.
 java.lang.Object[] getSelectedObjects()
          Returns the selected items on the list in an array of objects.
 int getSelectedRow()
          Get the index of the selected row
 java.lang.Object getValue(int fieldIdx)
          Gets a field value object from the currently selected row
 java.lang.Object getValue(int rowIdx, int fieldIdx)
          Gets a field value object from the specified row
 boolean isInteractiveTable()
          Check the if the table is interactive
 void last()
          Move to the last row
 void next()
          Move to the next row
 void paint(java.awt.Graphics g)
          Render the component
 void prev()
          Move to the previous row
 void removeItemListener(java.awt.event.ItemListener l)
          Removes the specified item listener so that it no longer receives item events from this list.
 void repaint()
          Request the component repaint itself
 void requestFocus()
          Forward the focus request to the content/table renderer
 void scrollToBottom()
          recalculates the size of the scroll area for dynamic table;
 void setBorderStyle(java.lang.String style)
          Set the style of the border
 void setBounds()
          recalculates the size of the scroll area for dynamic table;
 void setBounds(int x, int y, int w, int h)
          Sets the bounds for this component
 void setColWidth(int fieldIdx, int w)
          Set the table column width;
 void setComponentAt(int col, java.lang.String className)
          Set the type of component for a column
 void setDataModel(DataModel xmodel)
          Set the DataModel which we will be generating the table from
 void setHeaderStyle(java.lang.String style)
          Set the style of the header data
 void setInteractiveTable(boolean state)
          Set the user interaction state
 void setSelectedRow(int idx)
          Sets the indexof the selected row
 void setSelectedStyle(java.lang.String style)
          Set the style of the selected row
 void setStyle(java.lang.String style)
          Set the general style of the Table
 void setUpdateModelSelection(boolean doUpdate)
          Tie the model selection to this table's selection
 void update()
          implemented from ModelHolder interface
 
Methods inherited from class org.formaria.awt.ScrollPane
add, setNextScrollPanePolicy
 
Methods inherited from class java.awt.ScrollPane
addImpl, doLayout, eventTypeEnabled, getAccessibleContext, getHAdjustable, getHScrollbarHeight, getScrollbarDisplayPolicy, getScrollPosition, getVAdjustable, getViewportSize, getVScrollbarWidth, isWheelScrollingEnabled, layout, paramString, printComponents, processMouseWheelEvent, setLayout, setScrollPosition, setScrollPosition, setWheelScrollingEnabled
 
Methods inherited from class java.awt.Container
add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, list, list, locate, minimumSize, paintComponents, preferredSize, print, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, 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

Table

public Table()
Create a new table

Method Detail

update

public void update()
implemented from ModelHolder interface

Specified by:
update in interface ModelHolder

getComponentPanel

public java.awt.Container getComponentPanel()
Create a panel for components

Returns:
the component panel

setDataModel

public void setDataModel(DataModel xmodel)
Set the DataModel which we will be generating the table from

Specified by:
setDataModel in interface ModelHolder
Parameters:
xmodel - The DataModel of data

getModel

public DataModel getModel()
Get the underlying model.

Returns:
the model

checkSize

public void checkSize()
Recalculate and check the size of the content


setComponentAt

public void setComponentAt(int col,
                           java.lang.String className)
Set the type of component for a column

Parameters:
col - the field index
className - the class name

getContent

public java.lang.String getContent()
Set the model's name

Returns:
the name

addNotify

public void addNotify()
Creates the scroll pane's peer and sizes the child element.

Overrides:
addNotify in class java.awt.ScrollPane

setStyle

public void setStyle(java.lang.String style)
Set the general style of the Table

Specified by:
setStyle in interface StyleComponent
Parameters:
style - Style

setHeaderStyle

public void setHeaderStyle(java.lang.String style)
Set the style of the header data

Parameters:
style - Style

setSelectedStyle

public void setSelectedStyle(java.lang.String style)
Set the style of the selected row

Parameters:
style - Style

setBorderStyle

public void setBorderStyle(java.lang.String style)
Set the style of the border

Parameters:
style - Style

isInteractiveTable

public boolean isInteractiveTable()
Check the if the table is interactive

Returns:
true if the table supports user interaction

setInteractiveTable

public void setInteractiveTable(boolean state)
Set the user interaction state

Parameters:
state - true for an user interactive table.

setSelectedRow

public void setSelectedRow(int idx)
Sets the indexof the selected row

Specified by:
setSelectedRow in interface RowSelector
Parameters:
idx - the new selected row

getSelectedRow

public int getSelectedRow()
Get the index of the selected row

Specified by:
getSelectedRow in interface RowSelector
Returns:
the index of the selected row

first

public void first()
Move to the first row


prev

public void prev()
Move to the previous row


next

public void next()
Move to the next row


last

public void last()
Move to the last row


setUpdateModelSelection

public void setUpdateModelSelection(boolean doUpdate)
Tie the model selection to this table's selection

Parameters:
doUpdate - true to tie the selections together, false to ignore

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Sets the bounds for this component

Overrides:
setBounds in class java.awt.Component
Parameters:
x - the left coordinate
y - the top coordinate
w - the width dimension
h - the height dimension

setBounds

public void setBounds()
recalculates the size of the scroll area for dynamic table;


scrollToBottom

public void scrollToBottom()
recalculates the size of the scroll area for dynamic table;


setColWidth

public void setColWidth(int fieldIdx,
                        int w)
Set the table column width;

Parameters:
fieldIdx - the field index
w - the new column width

getValue

public java.lang.Object getValue(int fieldIdx)
Gets a field value object from the currently selected row

Parameters:
fieldIdx - the field offset
Returns:
the value

getValue

public java.lang.Object getValue(int rowIdx,
                                 int fieldIdx)
Gets a field value object from the specified row

Parameters:
rowIdx - the row offset
fieldIdx - the field offset
Returns:
the value

getFieldValue

public java.lang.String getFieldValue(int fieldIdx)
Gets a field value as a string from the currently selected row

Parameters:
fieldIdx - the field offset
Returns:
the value

getFieldValue

public java.lang.String getFieldValue(int rowIdx,
                                      int fieldIdx)
Gets a field value as a string from the specified row

Parameters:
rowIdx - the row offset
fieldIdx - the field offset
Returns:
the value

addItemListener

public void addItemListener(java.awt.event.ItemListener l)
Adds the specified item listener to receive item events from this list. Item events are sent in response to user input, but not in response to calls to select or deselect. If listener l is null, no exception is thrown and no action is performed.

Specified by:
addItemListener in interface java.awt.ItemSelectable
Parameters:
l - the item listener
Since:
JDK1.1
See Also:
removeItemListener( ItemListener ), ItemEvent, ItemListener

removeItemListener

public void removeItemListener(java.awt.event.ItemListener l)
Removes the specified item listener so that it no longer receives item events from this list. If listener l is null, no exception is thrown and no action is performed.

Specified by:
removeItemListener in interface java.awt.ItemSelectable
Parameters:
l - the item listener
Since:
JDK1.1
See Also:
addItemListener(java.awt.event.ItemListener), ItemEvent, ItemListener

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Returns the selected items on the list in an array of objects.

Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Returns:
an array of the selected components
See Also:
ItemSelectable

repaint

public void repaint()
Request the component repaint itself

Overrides:
repaint in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
Render the component

Overrides:
paint in class java.awt.Container
Parameters:
g - the graphics context

addMouseListener

public void addMouseListener(java.awt.event.MouseListener l)
Add a mouse listener

Overrides:
addMouseListener in class java.awt.Component
Parameters:
l - the new mouse listener

getComponentHashCode

public long getComponentHashCode()
Get the hash code to be used by the event handler for this component

Specified by:
getComponentHashCode in interface HashCode
Returns:
the hash code

requestFocus

public void requestFocus()
Forward the focus request to the content/table renderer

Overrides:
requestFocus in class java.awt.Component