org.netbeans.microedition.lcdui
Class TableItem

java.lang.Object
  extended by javax.microedition.lcdui.Item
      extended by javax.microedition.lcdui.CustomItem
          extended by org.netbeans.microedition.lcdui.TableItem
All Implemented Interfaces:
TableModelListener

public class TableItem
extends javax.microedition.lcdui.CustomItem
implements TableModelListener

An item that visualizes a table from TableModel.

The table can be larger than a screen in both directions - user can use a cursor to scroll in all directions.


Field Summary
 
Fields inherited from class javax.microedition.lcdui.CustomItem
KEY_PRESS, KEY_RELEASE, KEY_REPEAT, NONE, POINTER_DRAG, POINTER_PRESS, POINTER_RELEASE, TRAVERSE_HORIZONTAL, TRAVERSE_VERTICAL
 
Fields inherited from class javax.microedition.lcdui.Item
BUTTON, HYPERLINK, LAYOUT_2, LAYOUT_BOTTOM, LAYOUT_CENTER, LAYOUT_DEFAULT, LAYOUT_EXPAND, LAYOUT_LEFT, LAYOUT_NEWLINE_AFTER, LAYOUT_NEWLINE_BEFORE, LAYOUT_RIGHT, LAYOUT_SHRINK, LAYOUT_TOP, LAYOUT_VCENTER, LAYOUT_VEXPAND, LAYOUT_VSHRINK, PLAIN
 
Constructor Summary
TableItem(javax.microedition.lcdui.Display display, java.lang.String label)
          Creates a new instance of TableItem without any model.
TableItem(javax.microedition.lcdui.Display display, java.lang.String label, TableModel model)
          Creates a new instance of TableItem with a model.
TableItem(javax.microedition.lcdui.Display display, java.lang.String label, TableModel model, ColorSchema colorSchema)
          Creates a new instance of TableItem with a model.
 
Method Summary
 ColorSchema getColorSchema()
          Gets color schema currently in use
 javax.microedition.lcdui.Font getHeadersFont()
          Gets font used to paint the column names (headers) of the table
protected  int getMinContentHeight()
          implementation of the abstract method
protected  int getMinContentWidth()
           
protected  int getPrefContentHeight(int width)
          implementation of the abstract method
protected  int getPrefContentWidth(int height)
          implementation of the abstract method
 int getSelectedCellColumn()
          Gets the column position of the cursor in the table.
 int getSelectedCellRow()
          Gets the row position of the cursor in the table.
 java.lang.String getTitle()
          Gets title of the table.
 javax.microedition.lcdui.Font getTitleFont()
          Gets font used to paint the table title
 javax.microedition.lcdui.Font getValuesFont()
          Gets font used to paint the table cell values
 boolean isBorders()
          Should the table use borders
protected  void paint(javax.microedition.lcdui.Graphics g, int width, int height)
          implementation of the abstract method
 void setBorders(boolean showBorders)
          Sets state whether the table should be visualized with or without borders.
 void setColorSchema(ColorSchema colorSchema)
          Sets color schema to be used with this component.
 void setHeadersFont(javax.microedition.lcdui.Font headersFont)
          Sets the font to be used to paint title.
 void setModel(TableModel model)
          Sets a new model to the table.
 void setTitle(java.lang.String tableTitle)
          Sets title of the table.
 void setTitleFont(javax.microedition.lcdui.Font titleFont)
          Sets the font to be used to paint title.
 void setValuesFont(javax.microedition.lcdui.Font valuesFont)
          Sets the font to be used to paint title.
protected  void sizeChanged(int w, int h)
          implementation of the abstract method - if the item size has changed, simply repaint the table
 void tableModelChanged(TableModel changedModel)
          Listener for changes of the model.
protected  boolean traverse(int dir, int viewportWidth, int viewportHeight, int[] visRect_inout)
          implementation of the abstract method
protected  void traverseOut()
          implementation of the abstract method
 
Methods inherited from class javax.microedition.lcdui.CustomItem
getGameAction, getInteractionModes, hideNotify, invalidate, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, showNotify
 
Methods inherited from class javax.microedition.lcdui.Item
addCommand, getLabel, getLayout, getMinimumHeight, getMinimumWidth, getPreferredHeight, getPreferredWidth, notifyStateChanged, removeCommand, setDefaultCommand, setItemCommandListener, setLabel, setLayout, setPreferredSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableItem

public TableItem(javax.microedition.lcdui.Display display,
                 java.lang.String label)
          throws java.lang.IllegalArgumentException
Creates a new instance of TableItem without any model.

Parameters:
display - non-null display parameter.
label - label for the item
Throws:
java.lang.IllegalArgumentException - if the display parameter is null

TableItem

public TableItem(javax.microedition.lcdui.Display display,
                 java.lang.String label,
                 TableModel model)
          throws java.lang.IllegalArgumentException
Creates a new instance of TableItem with a model.

Parameters:
display - non-null display parameter.
label - label for the item
model - a TableModel to be visualized by this item
Throws:
java.lang.IllegalArgumentException - if the display parameter is null

TableItem

public TableItem(javax.microedition.lcdui.Display display,
                 java.lang.String label,
                 TableModel model,
                 ColorSchema colorSchema)
          throws java.lang.IllegalArgumentException
Creates a new instance of TableItem with a model.

Parameters:
display - non-null display parameter.
label - label for the item
model - a TableModel to be visualized by this item
colorSchema - a color schema to be used. If set to null, SystemCOlorSchema will be used
Throws:
java.lang.IllegalArgumentException - if the display parameter is null
Method Detail

setColorSchema

public void setColorSchema(ColorSchema colorSchema)
Sets color schema to be used with this component. If set to null SystemColorSchema will be used


getColorSchema

public ColorSchema getColorSchema()
Gets color schema currently in use


getTitle

public java.lang.String getTitle()
Gets title of the table.

Returns:
title string or null if there is no title defined

setTitle

public void setTitle(java.lang.String tableTitle)
Sets title of the table. The difference between title and label specified in the constructor is, that the title appears in the table (it is surrounded by the borders). Title can be null if no title should be shown.

The table is automatically repainted when a new title is set.

Parameters:
tableTitle - title for the table. Can be null

isBorders

public boolean isBorders()
Should the table use borders

Returns:
true if the table will be painted with borders. False if it will be borderless.

setBorders

public void setBorders(boolean showBorders)
Sets state whether the table should be visualized with or without borders.

The table is automatically repainted when the state is changed.

Parameters:
showBorders - true if the borders should be painted, false otherwise

setModel

public void setModel(TableModel model)
              throws java.lang.IllegalArgumentException
Sets a new model to the table. The table gets automatically repainted accordingly to a new model.

Parameters:
model - a new model to be visualized - cannot be null
Throws:
java.lang.IllegalArgumentException - if the model parameter is null

getTitleFont

public javax.microedition.lcdui.Font getTitleFont()
Gets font used to paint the table title

Returns:
title font

setTitleFont

public void setTitleFont(javax.microedition.lcdui.Font titleFont)
Sets the font to be used to paint title. If null is specified, the default font (bold version of static text font) will be used.

When the font changes, the table gets automatically repainted.

Parameters:
titleFont - font to be used for painting table title, might be null.

getValuesFont

public javax.microedition.lcdui.Font getValuesFont()
Gets font used to paint the table cell values

Returns:
values font

setValuesFont

public void setValuesFont(javax.microedition.lcdui.Font valuesFont)
Sets the font to be used to paint title. If null is specified, the default font (static text font) will be used.

When the font changes, the table gets automatically repainted.

Parameters:
valuesFont - font used for painting values, might be null

getHeadersFont

public javax.microedition.lcdui.Font getHeadersFont()
Gets font used to paint the column names (headers) of the table

Returns:
headers font

setHeadersFont

public void setHeadersFont(javax.microedition.lcdui.Font headersFont)
Sets the font to be used to paint title. If null is specified, the default font (bold static text font) will be used.

When the font changes, the table gets automatically repainted.

Parameters:
headersFont - font used for painting column names (headers), might be null

getSelectedCellRow

public int getSelectedCellRow()
Gets the row position of the cursor in the table.

Returns:
selected cell row

getSelectedCellColumn

public int getSelectedCellColumn()
Gets the column position of the cursor in the table.

Returns:
selected cell column

getMinContentHeight

protected int getMinContentHeight()
implementation of the abstract method

Specified by:
getMinContentHeight in class javax.microedition.lcdui.CustomItem
Returns:
minimal content height

getMinContentWidth

protected int getMinContentWidth()
Specified by:
getMinContentWidth in class javax.microedition.lcdui.CustomItem

getPrefContentHeight

protected int getPrefContentHeight(int width)
implementation of the abstract method

Specified by:
getPrefContentHeight in class javax.microedition.lcdui.CustomItem
Parameters:
width -
Returns:
preferred contnent height

getPrefContentWidth

protected int getPrefContentWidth(int height)
implementation of the abstract method

Specified by:
getPrefContentWidth in class javax.microedition.lcdui.CustomItem
Parameters:
height -
Returns:
preferred content width

paint

protected void paint(javax.microedition.lcdui.Graphics g,
                     int width,
                     int height)
implementation of the abstract method

Specified by:
paint in class javax.microedition.lcdui.CustomItem
Parameters:
g -
width -
height -

sizeChanged

protected void sizeChanged(int w,
                           int h)
implementation of the abstract method - if the item size has changed, simply repaint the table

Overrides:
sizeChanged in class javax.microedition.lcdui.CustomItem
Parameters:
w -
h -

traverse

protected boolean traverse(int dir,
                           int viewportWidth,
                           int viewportHeight,
                           int[] visRect_inout)
implementation of the abstract method

Overrides:
traverse in class javax.microedition.lcdui.CustomItem

traverseOut

protected void traverseOut()
implementation of the abstract method

Overrides:
traverseOut in class javax.microedition.lcdui.CustomItem

tableModelChanged

public void tableModelChanged(TableModel changedModel)
Listener for changes of the model. Just repaints the table when any change happened to the table model of this table.

Specified by:
tableModelChanged in interface TableModelListener
Parameters:
changedModel -