Java Reference
In-Depth Information
Display 18.9
Labels with Changing Visibility
(part 3 of 3)
54 {
55 String actionCommand = e.getActionCommand();
56 if (actionCommand.equals("Wave"))
57 {
58 wavingLabel.setVisible(
true
);
59 standingLabel.setVisible(
false
);
60 }
61
else if
(actionCommand.equals("Stop"))
62 {
63 standingLabel.setVisible(
true
);
64 wavingLabel.setVisible(
false
);
65 }
66
else
67 System.out.println("Unanticipated error.");
68 }
69 }
Resulting GUI
(After clicking Stop button)
Resulting GUI
(After clicking Wave button)