CLASS | Method and Description |
---|---|
Component extends Object |
public boolean action(Event evt, Object what); This method determines what happen if action events on the Component occur. This method is usually implemented for applets. |
Label extends Component |
public Label(); Constructor method. |
public Label(String label) Constructor method. Creates a new Label with the given label as its text. | |
public void setText(String label); Sets the text of the Label to be the String given. | |
Button extends Component |
public Button(String label); Constructor method. Creates a new Button with the label as its text. |
TextField extends TextComponent |
public TextField(); Constructor method. |
public TextField(int cols); Constructor method. Creates a new TextField with width of the specified columns. | |
public TextField(String text, int cols); Constructor method. Creates a new TextField with width of the specified columns and initial text the given text. | |
TextComponent extends Component |
public void setText(String t); Sets the text of the TextComponent. |
public String getText(); Gets the text of the TextComponent. | |
Container extends Component |
public void setLayout(LayoutManager mgr); Sets the LayoutManager for this Container. |
public Component add(Component comp); Adds the Component to the Container using the Container's LayoutManager. This form of add is used with FlowLayout and GridLayout. | |
public Component add(String name, Component comp); Adds the Component to the Container using the Container's LayoutManager. This form of add is used with BorderLayout where the name specifies in which of the five BorderLayout positions the Component should be placed. | |
Panel extends Container |
public Panel(); Constructor method. Panels are used to hold other GUI components. The default LayoutManager for a Panel is FlowLayout. |
Applet extends Panel |
The Applet class is not part of the AWT. |
public void init(); The init method performs initialization for the applet and happens first when the applet is loaded into the web browser or appletviewer. Generally, one sets the LayoutManager and adds the components for the Applet GUI in the init method. | |
LayoutManager | LayoutManagers determine how to arrange Commponents in a Container. Concrete examples of LayoutManagers are FlowLayout, GridLayout, and BorderLayout. |
FlowLayout implements LayoutManager |
public FlowLayout(); Constructor method. Creates a layout manager which arranges components from left to right in rows. It fits as many components as it can in a row before moving on to the next row. |
GridLayout implements LayoutManager |
public GridLayout(int rows, int cols); Constructor method. Creates a layout manager which divides the Container into the specified number of rows and columns and arranges the components in those rows and columns from left-to-right and from top-to-bottom. |
BorderLayout implements LayoutManager |
public BorderLayout(); Constructor method. Creates a layout manager which adds components with the names "North," "South," "East," "West," and "Center." These named components are arranged along the edges and in the center of the container. |