0% found this document useful (0 votes)
10 views2 pages

AWT (Group 1) - B

AWT provides GUI components and classes that allow developers to create platform-independent windowed applications and graphical user interfaces in Java. It includes common components like frames, text fields, labels, and buttons. AWT supports event-driven programming and drawing graphics. Examples show how to create a basic frame with a text field and label, and how to add a button and respond to click events.

Uploaded by

OLI
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)
10 views2 pages

AWT (Group 1) - B

AWT provides GUI components and classes that allow developers to create platform-independent windowed applications and graphical user interfaces in Java. It includes common components like frames, text fields, labels, and buttons. AWT supports event-driven programming and drawing graphics. Examples show how to create a basic frame with a text field and label, and how to add a button and respond to click events.

Uploaded by

OLI
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
You are on page 1/ 2

1

Introduction to AWT
provides a
 AWT, which stands for Abstract Window Toolkit, is a set of set of components that you can use to create
graphical user interface (GUI) components and classes in Java graphical user interfaces (GUIs) in Java
that allow developers to create platform-independent applications. These components are part of
windowed applications and graphical user interfaces. the `java.awt` package. Here are some of the
common AWT components:
 The Abstract Window Toolkit (AWT) is a set of application
1. **Frame**: A top-level window with a
programming interfaces (APIs) provided by Java for creating
graphical user interfaces (GUIs) in Java applications. title and border. Frames are typically used
as the main application window.
 AWT is part of the Java Foundation Classes (JFC) and serves 2. **TextField**: An input component for
as the foundation for building GUI components in Java.
single-line text input. Users can type text
into a text field.

Key features of AWT include: 3. **Label**: A non-editable text component


used for displaying text or captions in a GUI.

1. GUI Component Classes: AWT provides a wide 4. **Button**: A clickable button that can
range of classes for creating common GUI components trigger actions when clicked. You can add
action listeners to buttons to handle events.
like buttons, checkboxes, text fields, and more.
2. Layout Managers: AWT includes layout manager
classes that help in arranging GUI components within
containers, ensuring that they adapt to different screen
sizes and orientations.
3. Event Handling: AWT supports event-driven
programming, allowing developers to define actions or
responses to user interactions (e.g., button clicks or
mouse movements) through event listeners.
4. Graphics and Drawing: AWT provides classes and
methods for drawing graphics, shapes, and images on
GUI components and canvases.
5. Platform Independence: AWT was designed to be
platform-independent, allowing Java GUI applications to
run on various operating systems without modification. Fig 1.1

Remark : GUI is a visual way for users to interact with a computer or software application through graphical elements like
windows, icons, buttons, and menus, rather than using text-based commands.

Software Enginnering 1
2

Examples
E x a m p l e s
import java.awt.*; // this code shows how text field
inserted in frame
class myframe {
package javaapplication1;
myframe(){
import java.awt.*;
Frame f=new Frame();
class myframe {
f.setVisible(true);
myframe(){
f.setSize(400,400);
Frame f=new Frame();
f.setTitle("food app");
f.setSize(400,400);
f.setResizable(false);
f.setTitle("food app");
}
f.setResizable(false);
}
TextField t=new TextField();
public class JavaApplication2 {
t.setBounds(10,10,30,20);
public static void main(String[] args) {
f.add(t);
myframe m=new myframe();
f.setVisible(true);
}
f.setLayout(new FlowLayout());
} Output : }
}
public class JavaApplication1 {
public static void main(String[] args)
{
myframe m=new myframe();
}

} Output :
// this is how label works within frame
package javaapplication1;
import java.awt.*;
class myframe {
myframe(){
Frame f=new Frame();
f.setSize(400,400);
// this code shows how button inserted in
f.setTitle("food app"); frame
f.setResizable(false); package javaapplication1;
Label l1 =new Label("name"); import java.awt.*;
f.add(l1); class myframe {
f.setVisible(true); myframe(){
} Frame f=new Frame();
} f.setVisible(true);
public class JavaApplication1 { f.setSize(400,400);
public static void main(String[] args) { f.setTitle("food app");
myframe m=new myframe(); f.setResizable(false);
} Button b=new Button("submit");

} Output : f.add(b);
f.setLayout(new FlowLayout())
}
}
public class JavaApplication1 {
public static void main(String[] args)
{
myframe m=new myframe();
}

} Output :

EPHREM -MEKONNEN HAILEAB ZINABU EBRAHIM JENBERU


NSR/893/13 NSR/T/AM/14/640 NSR/796/13
Software Enginnering 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy