com.sun.lwuit.table
Class Table

java.lang.Object
  extended by com.sun.lwuit.Component
      extended by com.sun.lwuit.Container
          extended by com.sun.lwuit.table.Table
All Implemented Interfaces:
Animation, StyleListener

public class Table
extends Container

The table class represents a grid of data that can be used for rendering a grid of components/labels. The table reflects and updates the underlying model data.


Field Summary
static int INNER_BORDERS_ALL
          Constant denoting that inner borders should be drawn fully
static int INNER_BORDERS_COLS
          Constant denoting that only inner borders columns should be drawn
static int INNER_BORDERS_NONE
          Constant denoting that inner borders should not be drawn at all
static int INNER_BORDERS_ROWS
          Constant denoting that only inner borders rows should be drawn
 
Fields inherited from class com.sun.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Constructor Summary
Table()
          Constructor for usage by GUI builder and automated tools, normally one should use the version that accepts the model
Table(TableModel model)
          Create a table with a new model
Table(TableModel model, boolean includeHeader)
          Create a table with a new model
 
Method Summary
protected  Component createCell(java.lang.Object value, int row, int column, boolean editable)
          Creates a cell based on the given value
protected  TableLayout.Constraint createCellConstraint(java.lang.Object value, int row, int column)
          Creates the table cell constraint for the given cell, this method can be overriden for the purposes of modifying the table constraints.
 void deinitialize()
          Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.
 int getCellAlignment()
          Indicates the alignment of the cells see label alignment for details
 int getCellColumn(Component cell)
          Returns the column in which the given cell is placed
 int getCellRow(Component cell)
          Returns the row in which the given cell is placed
 int getInnerBorderMode()
          Returns the current inner border mode
 TableModel getModel()
          Returns the model instance
 java.lang.String[] getPropertyNames()
          A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code
 java.lang.Class[] getPropertyTypes()
          Matches the property names method (see that method for further details).
 java.lang.Object getPropertyValue(java.lang.String name)
          Returns the current value of the property name, this method is used by the GUI builder
 int getSelectedColumn()
          Returns the selected column in the table
 int getSelectedRow()
          Returns the selected row in the table
 int getTitleAlignment()
          Indicates the alignment of the title see label alignment for details
 void initComponent()
          Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state
 boolean isDrawBorder()
          Indicates whether the table border should be drawn
 boolean isIncludeHeader()
          Indicates whether the table should render a table header as the first row
protected  void paintGlass(Graphics g)
          This method can be overriden by a component to draw on top of itself or its children after the component or the children finished drawing in a similar way to the glass pane but more refined per component
 void setBorderSpacing(int horizontal, int vertical)
          Sets the spacing of cells border (relevant only for separate borders and not for collapsed)
 void setCellAlignment(int cellAlignment)
          Indicates the alignment of the cells see label alignment for details
 void setCollapseBorder(boolean collapseBorder)
          Indicates whether the borders of the cells should collapse to form a one line border
 void setDrawBorder(boolean drawBorder)
          Indicates whether the table border should be drawn
 void setDrawEmptyCellsBorder(boolean drawEmptyCellsBorder)
          Indicates whether empty cells should have borders (relevant only for separate borders and not for collapsed)
 void setIncludeHeader(boolean includeHeader)
          Indicates whether the table should render a table header as the first row
 void setInnerBorderMode(int innerBorder)
          Sets how to draw the inner border (All of it, only rows/columns, none, groups) Note that setting to any mode other than NONE/ALL will result in the border drawing as collapsed whether this is a collpased border or not
 void setModel(TableModel model)
          Replaces the underlying model
 java.lang.String setPropertyValue(java.lang.String name, java.lang.Object value)
          Sets a new value to the given property, returns an error message if failed and null if successful.
 void setTitleAlignment(int titleAlignment)
          Indicates the alignment of the title see label alignment for details
protected  boolean shouldDrawInnerBorderAfterRow(int row)
          Returns whether an inner border should be drawn after the specified row.
 
Methods inherited from class com.sun.lwuit.Container
addComponent, addComponent, addComponent, addComponent, animateLayout, animateLayoutAndWait, applyRTL, calcPreferredSize, contains, dragInitiated, drop, findFirstFocusable, flushReplace, getBottomGap, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getScrollIncrement, getSideGap, invalidate, isEnabled, isScrollableX, isScrollableY, keyPressed, keyReleased, layoutContainer, paint, paintBackground, paramString, pointerHover, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout
 
Methods inherited from class com.sun.lwuit.Component
addFocusListener, animate, calcScrollSize, contains, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, drawDraggedImage, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentForm, getDirtyRegion, getDisabledStyle, getDragImage, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID, getUnselectedStyle, getWidth, getVisibleBounds, getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle, installDefaultPainter, isAlwaysTensile, isDragActivated, isDragAndDropOperation, isDraggable, isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInitialized, isRTL, isScrollable, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isSnapToGrid, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerDragged, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHideInPortrait, setInitialized, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setRTL, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle, setWidth, setVisible, setX, setY, styleChanged, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INNER_BORDERS_NONE

public static final int INNER_BORDERS_NONE
Constant denoting that inner borders should not be drawn at all

See Also:
Constant Field Values

INNER_BORDERS_ROWS

public static final int INNER_BORDERS_ROWS
Constant denoting that only inner borders rows should be drawn

See Also:
Constant Field Values

INNER_BORDERS_COLS

public static final int INNER_BORDERS_COLS
Constant denoting that only inner borders columns should be drawn

See Also:
Constant Field Values

INNER_BORDERS_ALL

public static final int INNER_BORDERS_ALL
Constant denoting that inner borders should be drawn fully

See Also:
Constant Field Values
Constructor Detail

Table

public Table()
Constructor for usage by GUI builder and automated tools, normally one should use the version that accepts the model


Table

public Table(TableModel model)
Create a table with a new model

Parameters:
model - the model underlying this table

Table

public Table(TableModel model,
             boolean includeHeader)
Create a table with a new model

Parameters:
model - the model underlying this table
includeHeader - Indicates whether the table should render a table header as the first row
Method Detail

getSelectedRow

public int getSelectedRow()
Returns the selected row in the table

Returns:
the offset of the selected row in the table if a selection exists

getSelectedColumn

public int getSelectedColumn()
Returns the selected column in the table

Returns:
the offset of the selected column in the table if a selection exists

paintGlass

protected void paintGlass(Graphics g)
Description copied from class: Container
This method can be overriden by a component to draw on top of itself or its children after the component or the children finished drawing in a similar way to the glass pane but more refined per component

Overrides:
paintGlass in class Container
Parameters:
g - the graphics context

createCell

protected Component createCell(java.lang.Object value,
                               int row,
                               int column,
                               boolean editable)
Creates a cell based on the given value

Parameters:
value - the new value object
row - row number, -1 for the header rows
column - column number
editable - true if the cell is editable
Returns:
cell component instance

initComponent

public void initComponent()
Description copied from class: Component
Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state

Overrides:
initComponent in class Component

deinitialize

public void deinitialize()
Description copied from class: Component
Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.

Overrides:
deinitialize in class Component

setModel

public void setModel(TableModel model)
Replaces the underlying model

Parameters:
model - the new model

getModel

public TableModel getModel()
Returns the model instance

Returns:
the model instance

isDrawBorder

public boolean isDrawBorder()
Indicates whether the table border should be drawn

Returns:
the drawBorder

setDrawBorder

public void setDrawBorder(boolean drawBorder)
Indicates whether the table border should be drawn

Parameters:
drawBorder - the drawBorder to set

setInnerBorderMode

public void setInnerBorderMode(int innerBorder)
Sets how to draw the inner border (All of it, only rows/columns, none, groups) Note that setting to any mode other than NONE/ALL will result in the border drawing as collapsed whether this is a collpased border or not

Parameters:
innerBorder - one of the INNER_BORDER_* constants

getInnerBorderMode

public int getInnerBorderMode()
Returns the current inner border mode

Returns:
the current inner border mode (one of the INNER_BORDER_* constants)

shouldDrawInnerBorderAfterRow

protected boolean shouldDrawInnerBorderAfterRow(int row)
Returns whether an inner border should be drawn after the specified row. This allows customization in subclasses to create for example the effects of segments in atable, i.e. instead of a line after each row - lines after "chunks" of rows. Note that this is queried only when the inner border mode is set to INNER_BORDER_ROWS

Parameters:
row - The row in question
Returns:
true to draw inner border, false otherwise

setCollapseBorder

public void setCollapseBorder(boolean collapseBorder)
Indicates whether the borders of the cells should collapse to form a one line border

Parameters:
collapseBorder - true to collapse (default), false for separate borders

setDrawEmptyCellsBorder

public void setDrawEmptyCellsBorder(boolean drawEmptyCellsBorder)
Indicates whether empty cells should have borders (relevant only for separate borders and not for collapsed)

Parameters:
drawEmptyCellsBorder - - true to draw (default), false otherwise

setBorderSpacing

public void setBorderSpacing(int horizontal,
                             int vertical)
Sets the spacing of cells border (relevant only for separate borders and not for collapsed)

Parameters:
horizontal - - The horizontal spacing
vertical - - The vertical spacing

getTitleAlignment

public int getTitleAlignment()
Indicates the alignment of the title see label alignment for details

Returns:
the title alignment
See Also:
Label.setAlignment(int)

setTitleAlignment

public void setTitleAlignment(int titleAlignment)
Indicates the alignment of the title see label alignment for details

Parameters:
titleAlignment - the title alignment
See Also:
Label.setAlignment(int)

getCellColumn

public int getCellColumn(Component cell)
Returns the column in which the given cell is placed

Parameters:
cell - the component representing the cell placed in the table
Returns:
the column in which the cell was placed in the table

getCellRow

public int getCellRow(Component cell)
Returns the row in which the given cell is placed

Parameters:
cell - the component representing the cell placed in the table
Returns:
the row in which the cell was placed in the table

getCellAlignment

public int getCellAlignment()
Indicates the alignment of the cells see label alignment for details

Returns:
the cell alignment
See Also:
Label.setAlignment(int)

setCellAlignment

public void setCellAlignment(int cellAlignment)
Indicates the alignment of the cells see label alignment for details

Parameters:
cellAlignment - the table cell alignment
See Also:
Label.setAlignment(int)

isIncludeHeader

public boolean isIncludeHeader()
Indicates whether the table should render a table header as the first row

Returns:
the includeHeader

setIncludeHeader

public void setIncludeHeader(boolean includeHeader)
Indicates whether the table should render a table header as the first row

Parameters:
includeHeader - the includeHeader to set

createCellConstraint

protected TableLayout.Constraint createCellConstraint(java.lang.Object value,
                                                      int row,
                                                      int column)
Creates the table cell constraint for the given cell, this method can be overriden for the purposes of modifying the table constraints.

Parameters:
value - the value of the cell
row - the table row
column - the table column
Returns:
the table constraint

getPropertyNames

public java.lang.String[] getPropertyNames()
Description copied from class: Component
A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code

Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation

getPropertyTypes

public java.lang.Class[] getPropertyTypes()
Description copied from class: Component
Matches the property names method (see that method for further details).

Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String name)
Description copied from class: Component
Returns the current value of the property name, this method is used by the GUI builder

Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property

setPropertyValue

public java.lang.String setPropertyValue(java.lang.String name,
                                         java.lang.Object value)
Description copied from class: Component
Sets a new value to the given property, returns an error message if failed and null if successful. Notice that some builtin properties such as "$designMode" might be sent to components to indicate application state.

Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null