Skip to main content


com.sun.lwuit.table
Class TableLayout

java.lang.Object
  
extended by com.sun.lwuit.layouts.Layout extended by com.sun.lwuit.table.TableLayout
public class TableLayout
extends Layout

Layout manager similar in spirit to HTML tables allowing rows and columns of varying width/height.


Nested Class Summary
static class TableLayout.Constraint
          Represents the layout constraint for an entry within the table indicating the desired position/behavior of the component.
 
Constructor Summary
TableLayout(int rows, int columns)
          A table must declare the amount of rows and columns in advance
 
Method Summary
 void addLayoutComponent(java.lang.Object value, Component comp, Container c)
          Some layouts can optionally track the addition of elements with meta-data that allows the user to "hint" on object positioning.
 TableLayout.Constraint createConstraint()
          Creates a new Constraint instance to add to the layout
 TableLayout.Constraint createConstraint(int row, int column)
          Creates a new Constraint instance to add to the layout
 boolean equals(java.lang.Object o)
           
 int getCellHorizontalSpan(int row, int column)
          Returns the spanning for the table cell at the given coordinate
 int getCellVerticalSpan(int row, int column)
          Returns the spanning for the table cell at the given coordinate
 int getColumnPosition(int col)
          Returns the position of the given table column.
 int getColumns()
          Get the number of columns
 Component getComponentAt(int row, int column)
          Returns the component at the given row/column
 java.lang.Object getComponentConstraint(Component comp)
          Returns the optional component constraint
static int getDefaultColumnWidth()
          Indicates the default (in percentage) for the column width, -1 indicates automatic sizing
static int getDefaultRowHeight()
          Indicates the default (in percentage) for the row height, -1 indicates automatic sizing
static int getMinimumSizePerColumn()
          Indicates the minimum size for a column in the table, this is applicable for tables that are not scrollable on the X axis.
 int getNextColumn()
          Returns the column where the next operation of add will appear
 int getNextRow()
          Returns the row where the next operation of add will appear
 Dimension getPreferredSize(Container parent)
          Returns the container preferred size
 int getRowPosition(int row)
          Returns the position of the given table row.
 int getRows()
          Get the number of rows
 boolean hasHorizontalSpanning()
          Indicates whether there is spanning within this layout
 boolean hasVerticalSpanning()
          Indicates whether there is spanning within this layout
 boolean isCellSpannedThroughHorizontally(int row, int column)
          Returns true if the cell at the given position is spanned through horizontally
 boolean isCellSpannedThroughVertically(int row, int column)
          Returns true if the cell at the given position is spanned through vertically
 void layoutContainer(Container parent)
          Layout the given parent container children
 void removeLayoutComponent(Component comp)
          Removes the component from the layout this operation is only useful if the layout maintains references to components within it
static void setDefaultColumnWidth(int w)
          Indicates the default (in percentage) for the column width, -1 indicates automatic sizing
static void setDefaultRowHeight(int h)
          Indicates the default (in percentage) for the row height, -1 indicates automatic sizing
static void setMinimumSizePerColumn(int minimumSize)
          Sets the minimum size for a column in the table, this is applicable for tables that are not scrollable on the X axis.
 java.lang.String toString()
           
 
Methods inherited from class com.sun.lwuit.layouts.Layout
hashCode, isOverlapSupported
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableLayout

public TableLayout(int rows,
                   int columns)
A table must declare the amount of rows and columns in advance

Parameters:
rows - rows of the table
columns - columns of the table
Method Detail

getRows

public int getRows()
Get the number of rows

Returns:
number of rows

getColumns

public int getColumns()
Get the number of columns

Returns:
number of columns

getComponentAt

public Component getComponentAt(int row,
                                int column)
Returns the component at the given row/column

Parameters:
row - the row of the component
column - the column of the component
Returns:
the component instance

layoutContainer

public void layoutContainer(Container parent)
Description copied from class: Layout
Layout the given parent container children

Specified by:
layoutContainer in class Layout
Parameters:
parent - the given parent container

getRowPosition

public int getRowPosition(int row)
Returns the position of the given table row. A valid value is only returned after the layout occurred.

Parameters:
row - the row in the table
Returns:
the Y position in pixels or -1 if layout hasn't occured/row is too large etc.

getColumnPosition

public int getColumnPosition(int col)
Returns the position of the given table column. A valid value is only returned after the layout occurred.

Parameters:
col - the column in the table
Returns:
the X position in pixels or -1 if layout hasn't occured/column is too large etc.

getPreferredSize

public Dimension getPreferredSize(Container parent)
Description copied from class: Layout
Returns the container preferred size

Specified by:
getPreferredSize in class Layout
Parameters:
parent - the parent container
Returns:
the container preferred size

getNextRow

public int getNextRow()
Returns the row where the next operation of add will appear

Returns:
the row where the next operation of add will appear

getNextColumn

public int getNextColumn()
Returns the column where the next operation of add will appear

Returns:
the column where the next operation of add will appear

addLayoutComponent

public void addLayoutComponent(java.lang.Object value,
                               Component comp,
                               Container c)
Description copied from class: Layout
Some layouts can optionally track the addition of elements with meta-data that allows the user to "hint" on object positioning.

Overrides:
addLayoutComponent in class Layout
Parameters:
value - optional meta data information, like alignment orientation
comp - the added component to the layout
c - the parent container

getCellHorizontalSpan

public int getCellHorizontalSpan(int row,
                                 int column)
Returns the spanning for the table cell at the given coordinate

Parameters:
row - row in the table
column - column within the table
Returns:
the amount of spanning 1 for no spanning

getCellVerticalSpan

public int getCellVerticalSpan(int row,
                               int column)
Returns the spanning for the table cell at the given coordinate

Parameters:
row - row in the table
column - column within the table
Returns:
the amount of spanning 1 for no spanning

isCellSpannedThroughVertically

public boolean isCellSpannedThroughVertically(int row,
                                              int column)
Returns true if the cell at the given position is spanned through vertically

Parameters:
row - cell row
column - cell column
Returns:
true if the cell is a part of a span for another cell

isCellSpannedThroughHorizontally

public boolean isCellSpannedThroughHorizontally(int row,
                                                int column)
Returns true if the cell at the given position is spanned through horizontally

Parameters:
row - cell row
column - cell column
Returns:
true if the cell is a part of a span for another cell

hasVerticalSpanning

public boolean hasVerticalSpanning()
Indicates whether there is spanning within this layout

Returns:
true if the layout makes use of spanning

hasHorizontalSpanning

public boolean hasHorizontalSpanning()
Indicates whether there is spanning within this layout

Returns:
true if the layout makes use of spanning

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Description copied from class: Layout
Removes the component from the layout this operation is only useful if the layout maintains references to components within it

Overrides:
removeLayoutComponent in class Layout
Parameters:
comp - the removed component from layout

getComponentConstraint

public java.lang.Object getComponentConstraint(Component comp)
Description copied from class: Layout
Returns the optional component constraint

Overrides:
getComponentConstraint in class Layout
Parameters:
comp - the component whose constraint should be returned
Returns:
the optional component constraint

createConstraint

public TableLayout.Constraint createConstraint()
Creates a new Constraint instance to add to the layout

Returns:
the default constraint

createConstraint

public TableLayout.Constraint createConstraint(int row,
                                               int column)
Creates a new Constraint instance to add to the layout

Parameters:
row - the row for the table starting with 0
column - the column for the table starting with 0
Returns:
the new constraint

setMinimumSizePerColumn

public static void setMinimumSizePerColumn(int minimumSize)
Sets the minimum size for a column in the table, this is applicable for tables that are not scrollable on the X axis. This will force the earlier columns to leave room for the latter columns.

Parameters:
minimumSize - the minimum width of the column

getMinimumSizePerColumn

public static int getMinimumSizePerColumn()
Indicates the minimum size for a column in the table, this is applicable for tables that are not scrollable on the X axis. This will force the earlier columns to leave room for the latter columns.

Returns:
the minimum width of the column

setDefaultColumnWidth

public static void setDefaultColumnWidth(int w)
Indicates the default (in percentage) for the column width, -1 indicates automatic sizing

Parameters:
w - width in percentage

getDefaultColumnWidth

public static int getDefaultColumnWidth()
Indicates the default (in percentage) for the column width, -1 indicates automatic sizing

Returns:
width in percentage

setDefaultRowHeight

public static void setDefaultRowHeight(int h)
Indicates the default (in percentage) for the row height, -1 indicates automatic sizing

Parameters:
h - height in percentage

getDefaultRowHeight

public static int getDefaultRowHeight()
Indicates the default (in percentage) for the row height, -1 indicates automatic sizing

Returns:
height in percentage

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class Layout


Copyright 2011 Oracle Corporation. All rights reserved. Use is subject to license terms.
 
 
Close
loading
Please Confirm
Close