// Set the displayed title of the screen.
mainScreen.setTitle("Custom Buttons Demo");
// Add a vertical field manager containing sample custom button fields.
final VerticalFieldManager vfm = new VerticalFieldManager();
// Rectangular button
vfm.add(new RichTextField(Field.NON_FOCUSABLE));
rectangle =
new CustomButtonField("Rectangle", CustomButtonField.RECTANGLE,
Field.FOCUSABLE);
rectangle.setChangeListener(this);
vfm.add(rectangle);
// Triangular button
vfm.add(new RichTextField(Field.NON_FOCUSABLE));
triangle =
new CustomButtonField("Triangle", CustomButtonField.TRIANGLE,
Field.FOCUSABLE);
triangle.setChangeListener(this);
vfm.add(triangle);
// Octagonal button
vfm.add(new RichTextField(Field.NON_FOCUSABLE));
octagon =
new CustomButtonField("Octagon", CustomButtonField.OCTAGON,
Field.FOCUSABLE);
octagon.setChangeListener(this);
vfm.add(octagon);
// The next two buttons showcase the ability to hold a fixed width
// for a button regardless of how long the text in the button is.
vfm.add(new RichTextField(Field.NON_FOCUSABLE));
fixedWidth1 =
new CustomButtonField("Fixed Width",
CustomButtonField.FIXED_WIDTH, Field.FOCUSABLE);
fixedWidth1.setChangeListener(this);
vfm.add(fixedWidth1);
vfm.add(new RichTextField(Field.NON_FOCUSABLE));
fixedWidth2 =
new CustomButtonField("Fixed Width: Long!",
CustomButtonField.FIXED_WIDTH, Field.FOCUSABLE);
fixedWidth2.setChangeListener(this);
vfm.add(fixedWidth2);
// Button that will always stretch the entire width of the screen.
vfm.add(new RichTextField(Field.NON_FOCUSABLE));
fullscreen =
new CustomButtonField("Full Screen",
CustomButtonField.FULLSCREEN, Field.FOCUSABLE);
fullscreen.setChangeListener(this);
vfm.add(fullscreen);
// Button with a coloured background
vfm.add(new RichTextField(Field.NON_FOCUSABLE));
colour =
new CustomButtonField("Colour",
CustomButtonField.COLOUR_BACKGROUND, Field.FOCUSABLE);
colour.setChangeListener(this);
vfm.add(colour);
// Button using a picture as a background. The picture will change
// when the button recieves focus.
vfm.add(new RichTextField(Field.NON_FOCUSABLE));
picture = new PictureBackgroundButtonField("Picture", Field.FOCUSABLE);
picture.setChangeListener(this);
vfm.add(picture);
mainScreen.add(vfm);
// We've completed construction of our UI objects. Push the MainScreen
// instance onto the UI stack for rendering.