0% found this document useful (0 votes)
3 views12 pages

Java Awt Correct Definitions Notes

Java programming language

Uploaded by

dharshinit06
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views12 pages

Java Awt Correct Definitions Notes

Java programming language

Uploaded by

dharshinit06
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

AWT Controls
Definition
AWT controls are graphical user interface (GUI) components provided by the Abstract Window Toolkit
that allow users to interact with a Java program, such as buttons, labels, text fields and checkboxes.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

2. AWT Class Hierarchy


Definition
The AWT class hierarchy represents the relationship between different classes in the AWT package.
Most GUI components are derived from the base class Component and organized through Container,
Window and Frame classes.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.
3. User Interface Components
Definition
User Interface components are visual elements such as buttons, labels, text fields and lists that are used
to build graphical interfaces for user interaction.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

4. Label
Definition
A Label is a simple AWT component used to display non■editable text in a window or container.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

5. Button
Definition
A Button is an AWT component that generates an action event when the user clicks it.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

6. Text Components
Definition
Text components are AWT controls that allow users to enter or display text, such as TextField and
TextArea.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

7. Checkbox
Definition
A Checkbox is a GUI component that allows the user to select or deselect an option.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

8. CheckboxGroup
Definition
CheckboxGroup is used to group multiple checkboxes so that only one option can be selected at a time,
similar to radio buttons.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

9. Choice
Definition
Choice is a dropdown list component that allows the user to select one item from a list of options.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

10. List Box


Definition
A List component displays a list of items from which the user can select one or more items.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

11. Panel
Definition
A Panel is a container used to group and organize other GUI components inside a window.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

12. Scroll Pane


Definition
ScrollPane is a container that provides automatic scroll bars when the contained component is larger
than the visible area.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

13. Menu
Definition
A Menu is a component used to create menu bars and menu items in a frame.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

14. Scroll Bar


Definition
A Scrollbar is a component that allows the user to scroll through content vertically or horizontally.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

15. Working with Frame Class


Definition
Frame is a top■level window in AWT that can contain other components such as buttons, labels and
menus.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

16. Colour
Definition
The Color class in AWT is used to set foreground and background colors of GUI components.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

17. Fonts
Definition
Fonts in AWT define the style, size and appearance of text displayed in GUI components.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

18. Layout Managers


Definition
Layout Managers automatically control the position and arrangement of components within a container.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

19. Event Handling


Definition
Event handling is the mechanism in Java used to respond to user actions such as button clicks, mouse
movements or key presses.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

20. Events
Definition
An event is an object that represents a change in the state of a component caused by user interaction.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

21. Event Sources


Definition
Event sources are objects that generate events when the user interacts with them.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

22. Event Listeners


Definition
Event listeners are interfaces that receive and handle events generated by event sources.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

23. Event Delegation Model


Definition
The event delegation model is a mechanism in which an event source sends an event to a registered
listener object for processing.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.
24. Handling Mouse and Keyboard Events
Definition
Mouse and keyboard events are handled using listener interfaces such as MouseListener and
KeyListener to detect user actions.
Syntax
Button b = new Button("Click");
Example
Example usage of the component in an AWT program.
Program
import [Link].*;
class Demo{
public static void main(String args[]){
Frame f = new Frame("AWT Example");
Button b = new Button("Click");
[Link](100,100,80,30);
[Link](b);
[Link](300,300);
[Link](null);
[Link](true);
}
}
Output
A window appears containing a button.

You might also like