Modify a Button's Characteristics
Let's examine ButtonDemo's constructor in more detail to see how LWT buttons are
made, and how their visibility and screen location can be changed. Scroll through the
Buttons.java file with the editor to find:
// The constructor for our screen
public ButtonScreen() {
// First button
// Second button, set to fill the screen
//
// Third button, disabled
// Fourth button, using the custom RoundButton class
//
//
// Fifth button, RoundButton class, located to right and
// level with the top of the previous button
//
//
//
// Assign each button a listener
50
b1 = new Button("Button");
add(b1);
b2 = new Button("Large Button");
b2.setRightEdge(Component.SCREEN_RIGHT, 0);
b2.setBottomEdge(Component.HEIGHT,
b2.getPreferredHeight() * 2);
b2.setVisible(false);
add(b2);
b3 = new Button("Disabled Button");
b3.setEnabled(false);
add(b3);
b4 = new RoundButton("Round");
b4.setEnabled(false);
b4.setVisible(false);
add(b4);
b5 = new RoundButton("Round");
b5.setLeftEdge(Component.PREVIOUS_COMPONENT_RIGHT,
0);
b5.setTopEdge(Component.PREVIOUS_COMPONENT_TOP, 0);
b5.setVisible(false);
add(b5);
b1.setComponentListener(this);
b2.setComponentListener(this);
b3.setComponentListener(this);
b4.setComponentListener(this);
b5.setComponentListener(this);