fds.micro.ui
Class RowPanel

java.lang.Object
  extended byjavax.microedition.lcdui.Displayable
      extended byjavax.microedition.lcdui.Canvas
          extended byfds.micro.ui.AbstractPanel
              extended byfds.micro.ui.RowPanel

public class RowPanel
extends AbstractPanel

This class implement a panel that manages components derivated from fds.micro.ui.Component, and places them in rows from top to bottom, and from left to right on each row.

It inherits from javax.microedition.lcdui.Canvas. Please see this super-class for generic details.

Warning: Use this class only if you want to have control on rendering. If possible, always prefer javax.microedition.lcdui.Form classe.

An added component is placed just on the right of the previous one on the same line.
You can control the standard horizontal space between two components by calling method setXInset() at panel construction time, or directly with a special constructor.
On a specific place, you can add extra space between components by calling method addSpace() between two append() calls.

To notify the container that next component must be placed on the next line, just call method nextRow(). You can control the standard vertical space between two lines by calling method setYInset() at panel construction time, or directly with a special constructor.

On a line, components can have different heights. You can control the vertical alignment by calling methods valignOnTop(), valignOnCenter() or valignOnBottom().
After calling one them, all next added components will follow the corresponding vertical alignment constraint.
By default, components are vertically centered.

Finally, you can define a TOP and LEFT margin for this container by calling setTopMargin() and setLeftMargin() methods.

Here is a simple example:

 ...
 // Panel with 10 as top and left margin, and 5 as x and y space between components
 RowPanel panel = new RowPanel(10, 10, 5, 5);
 
 // First Row: A big title
 StringItem title = new StringItem("Title");
 title.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_LARGE));
 panel.append(title);
 panel.nextRow();
 
 // Second row: Two check boxes separated by 20 more pixels
 panel.append(new CheckBox("Checkbox 1"));
 panel.addSpace(20);
 panel.append(new CheckBox("Checkbox 2"));
 panel.nextRow();
 
 // Third row: Two exclusive choices, the first in field mode, and the second as radio button, TOP aligned.
 panel.valignOnTop();
 panel.append(new ExclusiveChoice(new String[]{"One", "Two"}, true));
 panel.append(new ExclusiveChoice(new String[]{"One", "Two"}, false));
 ...
 

Author:
Frédéric DE STEUR
See Also:
Canvas

Field Summary
 
Fields inherited from class javax.microedition.lcdui.Canvas
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP
 
Constructor Summary
RowPanel()
          Build an empty panel.
RowPanel(int topMargin, int leftMargin, int xInset, int yInset)
          Build a panel with given insets.
 
Method Summary
 void addSpace(int width)
          Add a space between previous and next components.
 void forceLayout()
          You must call this method when you dynamically change components in this panel.
 int getLeftMargin()
          Gives the minimum number of pixels between screen left border and any component.
 int getTopMargin()
          Gives the minimum number of pixels between screen top border and any component.
 int getXInset()
          Get the number of pixels between two components on the same line.
 int getYInset()
          Get the number of pixels between two lines.
 void nextRow()
          Say the container to go to next row before inserting next component.
 void setLeftMargin(int leftMargin)
          Set the minimum number of pixels between screen left border and any component.
 void setTopMargin(int topMargin)
          Set the minimum number of pixels between screen top border and any component.
 void setXInset(int xInset)
          Change the number of pixels between two components on the same line.
 void setYInset(int yInset)
          Change the number of pixels between two lines.
 void valignOnBottom()
          Say the container to align next components on bottom of line.
 void valignOnCenter()
          Say the container to vertically center next components on line.
 void valignOnTop()
          Say the container to align next components on top of line.
 
Methods inherited from class fds.micro.ui.AbstractPanel
addContainerListener, append, contains, getComponent, getComponents, getCount, getFocusIndex, indexOf, indexOf, insert, isEmpty, lastIndexOf, lastIndexOf, remove, removeAll, removeContainerListener, replace, setBackground, setComponents, setFocusIndex, setFocusIndex
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getHeight, getKeyCode, getKeyName, getWidth, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, isDoubleBuffered, repaint, repaint, serviceRepaints
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, isShown, removeCommand, setCommandListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowPanel

public RowPanel()
Build an empty panel.


RowPanel

public RowPanel(int topMargin,
                int leftMargin,
                int xInset,
                int yInset)
Build a panel with given insets.

Parameters:
topMargin - The minimum number of pixels between screen top border and any component.
leftMargin - The minimum number of pixels between screen left border and any component.
xInset - The default number of pixels between two components on the same line.
yInset - The default number of pixels between two lines.
Method Detail

addSpace

public void addSpace(int width)
Add a space between previous and next components.

Parameters:
width - The width of space to add.

forceLayout

public void forceLayout()
You must call this method when you dynamically change components in this panel.


getLeftMargin

public int getLeftMargin()
Gives the minimum number of pixels between screen left border and any component.

Returns:
Returns the left margin in pixels.

getTopMargin

public int getTopMargin()
Gives the minimum number of pixels between screen top border and any component.

Returns:
Returns the top margin in pixels.

getXInset

public int getXInset()
Get the number of pixels between two components on the same line.

Returns:
the horizontal space (in pixels) between two components.

getYInset

public int getYInset()
Get the number of pixels between two lines.

Returns:
the vertical space (in pixels) between two lines.

nextRow

public void nextRow()
Say the container to go to next row before inserting next component.


setLeftMargin

public void setLeftMargin(int leftMargin)
Set the minimum number of pixels between screen left border and any component.

Parameters:
leftMargin - The left margin in pixels.

setTopMargin

public void setTopMargin(int topMargin)
Set the minimum number of pixels between screen top border and any component.

Parameters:
topMargin - The top margin in pixels.

setXInset

public void setXInset(int xInset)
Change the number of pixels between two components on the same line.

Parameters:
xInset - The horizontal space (in pixels) between two components.

setYInset

public void setYInset(int yInset)
Change the number of pixels between two lines.

Parameters:
yInset - The vertical space (in pixels) between two lines.

valignOnBottom

public void valignOnBottom()
Say the container to align next components on bottom of line.


valignOnCenter

public void valignOnCenter()
Say the container to vertically center next components on line.


valignOnTop

public void valignOnTop()
Say the container to align next components on top of line.