// Define rows and columns
final int rows = 4;
final int cols = 3;
// Instantiate a GridFieldManager with 4 rows and 3 columns
final GridFieldManager gridFieldManager =
new GridFieldManager(rows, cols, Field.FIELD_HCENTER);
// Add a field to the screen to display a phone number
_phoneNumberField =
new BasicEditField("Phone number: ", "", 15,
Field.NON_FOCUSABLE);
add(_phoneNumberField);
add(new SeparatorField());
// Instantiate button fields
_buttonFieldOne =
new ButtonField("1", ButtonField.NEVER_DIRTY
| ButtonField.CONSUME_CLICK);
_buttonFieldTwo =
new ButtonField("2", ButtonField.NEVER_DIRTY
| ButtonField.CONSUME_CLICK);
_buttonFieldThree =
new ButtonField("3", ButtonField.NEVER_DIRTY
| ButtonField.CONSUME_CLICK);
_buttonFieldFour =
new ButtonField("4", ButtonField.NEVER_DIRTY
| ButtonField.CONSUME_CLICK);
_buttonFieldFive =
new ButtonField("5", ButtonField.NEVER_DIRTY
| ButtonField.CONSUME_CLICK);
_buttonFieldSix =
new ButtonField("6", ButtonField.NEVER_DIRTY
| ButtonField.CONSUME_CLICK);
_buttonFieldSeven =
new ButtonField("7", ButtonField.NEVER_DIRTY
| ButtonField.CONSUME_CLICK);
_buttonFieldEight =
new ButtonField("8", ButtonField.NEVER_DIRTY
| ButtonField.CONSUME_CLICK);
_buttonFieldNine =
new ButtonField("9", ButtonField.NEVER_DIRTY
| ButtonField.CONSUME_CLICK);
_buttonFieldStar =
new ButtonField("*", ButtonField.NEVER_DIRTY
| ButtonField.CONSUME_CLICK);
_buttonFieldZero =
new ButtonField("0", ButtonField.NEVER_DIRTY
| ButtonField.CONSUME_CLICK);
_buttonFieldPound =
new ButtonField("#", ButtonField.NEVER_DIRTY
| ButtonField.CONSUME_CLICK);
// Add button fields to the GridFieldManager
gridFieldManager.add(_buttonFieldOne);
gridFieldManager.add(_buttonFieldTwo);
gridFieldManager.add(_buttonFieldThree);
gridFieldManager.add(_buttonFieldFour);
gridFieldManager.add(_buttonFieldFive);
gridFieldManager.add(_buttonFieldSix);
gridFieldManager.add(_buttonFieldSeven);
gridFieldManager.add(_buttonFieldEight);
gridFieldManager.add(_buttonFieldNine);
gridFieldManager.add(_buttonFieldStar);
gridFieldManager.add(_buttonFieldZero);
gridFieldManager.add(_buttonFieldPound);
// Add the GridFieldManager to a VerticalFieldManager
final VerticalFieldManager vfm =
new VerticalFieldManager(USE_ALL_WIDTH);
vfm.add(gridFieldManager);