|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.ui.Field
net.rim.device.api.ui.ScrollView
net.rim.device.api.ui.Manager
net.rim.device.api.ui.container.HorizontalFieldManager
net.rim.device.api.ui.container.SpinBoxFieldManager
public class SpinBoxFieldManager
Manages a set of SpinBoxField
s.
The spin box manager dictates the height of each row and the number of
rows that are shown for each spin box. If a SpinBoxField
is owned by a manager then SpinBoxField.setVisibleRows
and SpinBoxField.setRowHeight
will have no effect.
Note that row heights are fixed. Each row must have the same height.
To add spin boxes to the manager, use the SpinBoxFieldManager.add(net.rim.device.api.ui.Field)
or SpinBoxFieldManager.insert(net.rim.device.api.ui.Field, int)
methods
just like you would with any field manager. You may add non-SpinBoxField
fields to the manager, but it is not recommended. The spin boxes will be arranged
horizontally. Since the row heights are equal as well as the number of rows shown,
each spin box should line up accordingly.
Spin Boxes must have Field.isEditable()
be true in order to edit them.
The editablity can be toggled by clicking anywhere on the manager or spin box.
SpinBoxFieldManager.setClickToLock(boolean)
to specify that when a user clicks on the spin box or its manager,
it will be locked/unlocked for editing.
// an array of choices for the months.
final String[] MONTHS = { "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"};
// an array of choices for years
final String[] YEARS = { "2001", "2002", "2003", "2004", "2005", "2006", "2007",
"2008", "2009", "2010", "2011", "2012", "2013", "2014"};
// use a text spin box to display these choices
SpinBoxField monthSpinBox = new TextSpinBoxField(MONTHS);
SpinBoxField _yearsSpinBox = new TextSpinBoxField(YEARS);
// create a manager for these spin boxes
SpinBoxFieldManager spinBoxManager = new SpinBoxFieldManager();
// add the spin boxes
spinBoxManager.add(monthSpinBox);
spinBoxManager.add(yearsSpinBox);
// adjust properties
spinBoxManager.setVisibleRows(5);
spinBoxManager.setRowHeight(40);
// ...
// add the spin box manager to a screen or other manager.
// To retrieve selections, use the spin box field references directly
// or use manager.getField(index)
// ...
SpinBoxField
Field Summary |
---|
Fields inherited from class net.rim.device.api.ui.container.HorizontalFieldManager |
---|
LOCALE_AWARE_LAYOUT |
Fields inherited from class net.rim.device.api.ui.Manager |
---|
BOTTOMMOST, DOWNWARD, HORIZONTAL_SCROLL, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_MASK, HORIZONTAL_SCROLL_MASK, LEAVE_BLANK_SPACE, LEFTMOST, LEFTWARD, NO_HORIZONTAL_SCROLL, NO_HORIZONTAL_SCROLLBAR, NO_SCROLL_RESET, NO_VERTICAL_SCROLL, NO_VERTICAL_SCROLLBAR, QUANTA_FONT, RIGHTMOST, RIGHTWARD, TOPMOST, UPWARD, VERTICAL_SCROLL, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_MASK, VERTICAL_SCROLL_MASK |
Fields inherited from interface net.rim.device.api.ui.FocusChangeListener |
---|
FOCUS_CHANGED, FOCUS_GAINED, FOCUS_LOST |
Constructor Summary | ||
---|---|---|
SpinBoxFieldManager()
Default constructor with no style specified. |
||
SpinBoxFieldManager(long style)
Construct an instance while specifying a style. |
Method Summary | ||
---|---|---|
void |
add(Field field)
Adds a field to this manager. |
|
void |
focusChanged(Field field,
int eventType)
Called by a field when focus enters, leaves or changes. Handles redrawing the background of the spinbox when the focus changes. |
|
int |
getRowHeight()
Returns the height in pixels of a single row of the spin box. |
|
int |
getVisibleRows()
Returns the number of rows that each spin box shows. |
|
void |
insert(Field field,
int index)
Inserts a field into this manager. |
|
protected boolean |
invokeAction(int action)
Invokes an action on the field in this manager that currently has the focus. |
|
boolean |
isClickToLock()
Returns true if and only if the user can click the spin box to lock/unlock it for editing. |
|
void |
setClickToLock(boolean clickToLock)
Sets whether or not the user can click on the spinbox to lock/unlock it for editing. |
|
void |
setEditable(boolean editable)
Set the editable state of this field. |
|
void |
setRowHeight(int rowHeight)
Sets the row height for all rows in the spin box. |
|
void |
setVisibleRows(int numRows)
Sets the number of rows that will be displayed for each spin box. |
|
protected void |
sublayout(int maxWidth,
int maxHeight)
Lays out this manager's controlled fields. |
Methods inherited from class net.rim.device.api.ui.container.HorizontalFieldManager |
---|
getFieldAtLocation, getPreferredHeight, getPreferredWidth, nextFocus, subpaint |
Methods inherited from class net.rim.device.api.ui.ScrollView |
---|
configurationChanged, getHorizontalAdjustment, getVerticalAdjustment, getVisibleHeight, getVisibleWidth, onDisplay, onUndisplay, setCurrentLocation, setExtent, setHorizontalAdjustment, setHorizontalScroll, setHorizontalScroll, setScrollListener, setVerticalAdjustment, setVerticalScroll, setVerticalScroll, valueChanged, waitForScrolling |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SpinBoxFieldManager()
public SpinBoxFieldManager(long style)
style
- style bitmaskMethod Detail |
---|
public void setRowHeight(int rowHeight)
rowHeight
- the height of the row in pixels,
must be >e 0.public int getRowHeight()
public void setVisibleRows(int numRows)
numRows
- the number of rows to show,
should be odd,
must be greater than 0.public int getVisibleRows()
public void setClickToLock(boolean clickToLock)
clickToLock
- set to true if the user can click the spin box to lock/unlock it for editing.public boolean isClickToLock()
public void add(Field field)
Invoke this method to add a new field at the end of this manager's list of controlled fields.
Notice that only one manager is allowed to control any single field, and a field can never manage itself.
add
in class Manager
field
- Field to add.Manager#add
public void insert(Field field, int index)
Invoke this method to insert a new field into this manager's list of controlled fields. You provide the field to add, and the index position you wish the new field to occupy.
insert
in class Manager
field
- Field to insert.index
- Index at which to insert.Manager#insert
public void setEditable(boolean editable)
This method lets you change the style of this field by either adding,
or removing, the Field.EDITABLE
style.
setEditable
in class Field
editable
- If True, make this field editable; otherwise, make this
field non-editable.Manager#setEditable
protected void sublayout(int maxWidth, int maxHeight)
The framework invokes this method to direct this manager to lay out its controlled fields.
sublayout
in class HorizontalFieldManager
maxWidth
- Horizontal space available for this manager.maxHeight
- Vertical space available for this manager.Manager#sublayout
protected boolean invokeAction(int action)
invokeAction
in class Manager
action
- the action to be performed on the field in this manager that currently has
the focus.
true
if the action was consumed by the field on which the action was
performed; false
if the action was not consumed or no field has the focus in
this manager.Manager#invokeAction
public void focusChanged(Field field, int eventType)
Handles redrawing the background of the spinbox when the focus changes.
focusChanged
in interface FocusChangeListener
field
- The field that caused the focus event.eventType
- Indicates the type of focus event.FocusChangeListener
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.