The document provides notes on creating GUI applications in Java using AWT and Swing, focusing on the use of Frame and Applet. It outlines key methods for Frame, lifecycle methods for Applet, and introduces AWT controls like Button, Label, and Checkbox. Each control is described with its constructor and an example of usage.
The document provides notes on creating GUI applications in Java using AWT and Swing, focusing on the use of Frame and Applet. It outlines key methods for Frame, lifecycle methods for Applet, and introduces AWT controls like Button, Label, and Checkbox. Each control is described with its constructor and an example of usage.
- Frame is a top-level window in AWT with title and borders.
- Commonly used to create GUI applications. - Key methods: - setSize(width, height): sets frame size - setTitle("Title"): sets the window title - setVisible(true): makes the frame visible
4.3.2 Creating Windowed Programs using Applet
- Applet is a Java program that runs in a web browser.
- Extends java.applet.Applet class. - Lifecycle methods: - init(): initializes applet - start(): starts execution - paint(Graphics g): used for graphics or drawing - stop(), destroy(): handle cleanup
- Controls like Button, Label, Checkbox, etc. are part of AWT. - Requires importing java.awt.* package.
4.4.1 class Button
- Used to create a button.
- Constructor: Button(String label) - Example: Button b = new Button("Click");
4.4.2 class Label
- Displays a non-editable text.
- Constructor: Label(String text) - Example: Label l = new Label("Name:");
4.4.3 class Checkbox
- Represents a checkbox that can be either checked or unchecked. - Constructor: Checkbox(String label) - Example: Checkbox c = new Checkbox("Accept Terms");