| |
A "Button" is a user interface component. Here are some useful things
to do with buttons:
- Declare a button: Button myButton;
- Allocate a button: myButton = new Button();
myButton = new Button("label");
- Resize a button: myButton.setSize(int
width, int height);
*** only do this with the null layout manager
- Move a button: myButton.setLocation(int
topLeftX, int topLeftY);
*** only do this with the null layout manager
- Move and resize a button:
myButton.setBounds(int
topLeftX, int topLeftY, int width, int height);
- Handle button events:
To handle events, do three things. First, implement
"ActionListener". Second, "add" a "Button" to the
display. Third, define "actionPerformed".
Would you like to see a sample program that uses buttons?
|