Articles : JavaBoutique's Introduction to Java :
Using the AWT To Build User Interfaces :

Contents
Introduction
Decrypting the Inheritance Hierarchy
Constructors and Methods
Using the Online Documentation by Example

Constructors

The next interesting section of the online documentation will be the Constructor Index. The constructor index outlines any constructors that you can use to build the desired object.

In the case of the Button, you can see that it has two constructors (If you click on the constructors, you'll get a detailed description).

  • Button() which creates a button
  • Button(String) which creates a button with a given string to display

Thus, you know that you could easily use a Button in your code by using the syntax:

Button b = new Button();
or
Button b = new Button("Click Me");
 

Methods

You will also notice about a dozen methods that you can use to manipulate the button object.

All public methods are available to you using dot notation, and the parameters you need to pass to them are listed. For example, you know that if you use the setLabel() method, you will have to pass a string as a parameter. Notice also that if you click on the method, you will get a detailed description including its return type.

NEXT


Selena Sol contributes to the JavaBoutique's Introduction to Java. Selena currently works for Barclays Capital in London, one of the leading global investment banks in Europe and has worked as a software developer for the National Center for Human Genome research, Microline Software, Neuron Data, and Electric Eye in Singapore. Selena is perhaps best-known for creating the Public Domain Web Script Archive (Extropia) and writing several books on Web Programming (Perl, CGI, Java).
Email: selena@extropia.com