0% found this document useful (0 votes)
4 views3 pages

Computer Lp Lesson 9

Uploaded by

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

Computer Lp Lesson 9

Uploaded by

valleys829
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

PAGADIAN DIOCESAN SCHOOLS

HOLY CHILD’S ACADEMY


Pagadian City

LEARNING PLAN IN C O M P U T E R 10

Name: Section:

Lesson #: 9 Topic: Java Abstract Window Toolkit


Content Standards: The learners demonstrate an understanding of key concepts, underlying principles, and core
competencies in Programming (Java).
Performance Standards: The learners should be able to independently create or provide quality and marketable product
and or service in Programming (Java).
Learning Competencies: At the end of this lesson, the students can:
1. Understand the importance of Java GUI
2. Create a java program with Graphical User Interface.
Reference/s: Manansala, Estrelita T. et.al.,C++ and Java Programming Made Simple.The Library Publishing House, Inc.
Java AWT Tutorial - javatpoint
Values: Patience

INTRODUCTION

What do you think is the importance of buttons in certain application?

What is the general use of buttons?

INTERACTION

Concept Notes/Reading Materials


Java AWT (Abstract Window Toolkit) is an API to develop Graphical User Interface (GUI) or windows-based
applications in Java. The java.awt package provides classes for AWT API(application
programming interface) such as TextField, Label, TextArea,
RadioButton, CheckBox, Choice, List etc.

Java AWT Hierarchy


A. Container
The Container is a component in AWT that can contain another component like buttons, text-fields, labels etc. The
classes that extend Container class are known as container such as Frame, Dialog and Panel.
Note: A container itself is a component (see the above diagram), therefore we can add a container inside container.

Types of containers in Java AWT:


 Window
 Panel
 Frame
 Dialog
1. Window
The window is the container that has no borders and menu bars. You must use frame, dialog or another
window for creating a window. We need to create an instance of Window class to create this container.
2. Panel
The Panel is the container that doesn't contain title bar, border or menu bar. It is generic container for
holding the components. It can have other components like button, text field etc. An instance of Panel class
creates a container, in which we can add components.
3. Frame
The Frame is the container that contain title bar and border and can have menu bars. It can have other
components like button, text field, scroll-bar etc. Frame is most widely used container while developing an AWT
application.
Useful Methods of Component Class

Method Description

public void add(Component c) Inserts a component on this component.

public void setSize(int width,int height) Sets the size (width and height) of the
component.

public void setLayout(LayoutManager m) Defines the layout manager for the component.

public void setVisible(boolean status) Changes the visibility of the component, by


default false.

Two Ways to create a GUI using Frame in AWT


1. By extending Frame class (inheritance)
2. By creating the object of Frame class (association)

Let’s Practice: AWTExample1.java


1. import java.awt.*; // importing Java AWT class
2. public class AWTExample1 extends Frame { // extending Frame class to our class AWTExam
ple1
3.
4. AWTExample1() { // initializing using constructor
5.
6. Button b = new Button("Click Me!!"); // creating a button
7.
8. b.setBounds(30,100,80,30); // setting button position on screen
9. b.setBackground(Color.BLUE);
10. add(b); // adding button into frame
11.
12. setSize(300,300); // frame size 300 width and 300 height
13. setTitle("This is our basic AWT example"); // setting the title of Frame
14. setLayout(null); // no layout manager
15. setVisible(true); // now frame will be visible, by default it is not visible
16. }
17. public static void main(String args[]) { // main method
18.
19. AWTExample1 f = new AWTExample1(); // creating instance of Frame class
20. }
21. }

Learning Activity
Identification: Give what is asked.
______1. What is the complete meaning of the abbreviation AWT in java? It is an API to develop Graphical
User Interface (GUI) or windows-based applications in Java.
______2. -3 What are the two ways to create a GUI using Frame in AWT?

Complete the table by giving the correct method described below.

Method Description

_________4. Inserts a component on this component.

_________5. Sets the size (width and height) of the


component.

_________6. Defines the layout manager for the


component.

_________7. Changes the visibility of the component, by


default false.

______8. It is the container that has no borders and menu bars.


______9. It is the container that contain title bar and border and can have menu bars. It can have other
components like button, text field, scroll-bar.
______10. It is a component in AWT that can contain another component like buttons, text-fields, labels etc.
______11. It is the container that doesn't contain title bar, border or menu bar.
______12-15. The four types of containers in Java AWT.

You might also like