Button
Home Up Button Checkbox CheckboxGroup Choice Key List Menu Mouse Popup Window Text

 

A "Button" is a user interface component.  Here are some useful things to do with buttons:

  1.   Declare a button:   Button myButton;
  2.   Allocate a button:  myButton = new Button();
                                    myButton = new Button("label");
  3.   Resize a button:     myButton.setSize(int width, int height);
         *** only do this with the null layout manager
  4.   Move a button:       myButton.setLocation(int topLeftX, int topLeftY);
         *** only do this with the null layout manager
  5. Move and resize a button:    
               myButton.setBounds(int topLeftX, int topLeftY, int width, int height);
  6.   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?