Oop Ii-Introduction
Oop Ii-Introduction
Object-Oriented Programming II
RCS 212
John Sospeter
Assistant Lecturer
Faculty of Information and Communication Technology
Department of Computer Science
Ruaha Catholic University
How You Will be Graded
• Office
ICT Office No_02
• Email address
[email protected]
[email protected]
• Contact
Mobile no +255763160096
Whatsapp no: +8615524573830
Introduction to GUI
[Graphical User Interface]
Introduction to GUI
GUI
• Is a type of computer human interface on a
computer
• A computer human interface is a "means by which
people and computers communicate with each other
• Presents a user-friendly mechanism for interacting
within application.
• A GUI (pronounced “GOO-ee”) gives an application a
distinctive “look and feel.”
Introduction to GUI
• A GUI allows a computer user to move from application to application.
• When a GUI program is running, the user can click any of the buttons
and interact with any of the other on screen components in any order.
Because the program’s execution is driven by the series of events that
occur, we say that programs with GUIs are event-driven
Example of GUI
Example of GUI
JAVA GUI Libraries
• GUI-related classes are defined primarily in the java.awt and the javax.swing packages
• The Abstract Windowing Toolkit (AWT) was the original Java GUI package.
Problems: Limited to lowest common denominator (limited set of UI widgets); clunky to
use.
AWT stands for Abstract Window Toolkit AWT is the foundation of Swing and it implements GUI
components which was built on AWT.
AWT GUI components are heavy weight. Because Swing components are light weight Graphical User
components consumes comparatively high System Interface toolkit that includes a rich set of widgets
Resources than Swing. Components are depend on the
underlying operating System
AWT consumes comparatively high System Resources Swing consumes less System Resources.
than Swing.
AWT produces platform dependent components. i.e. the Swing will produce platform independent components.
program is dependent on the current Operating System. i.e. you can use it on any Operating System that
supports Java.
1. Component
2. Container
GUI Components
• A GUI component is an object that represents a screen
element such as a button or a text field.
• Dialog: It can be thought of like a pop-up window that pops out when
a message has to be displayed. It is not a fully functioning window
like the Frame.
Identify Components and Containers
Answers
Building a GUI
• A GUI is built in layers.
• Layout manager Is used to layout [or arrange] the GUI java components
inside a container
– Its job is to instruct components on how to arrange themselves so the GUI is
drawn correctly. Eg. BorderLayout, FlowLayout, GridLayout
Building a GUI
Simple Application X
OK A Label
JFrame
JLabel JTextField
The Containment hierarchy
Draw the Containment hierarchy
Swing Top Level Containers
• JWindow
– Basic no frills window, just a square on the screen
– WindowExample.java
• JFrame
– The basic Swing window. Offers basic window controls,
resizable
– FrameExample.java
• JDialog
– For building dialog boxes, e.g. File open/save
– DialogExample.java
• JApplet
– For building applets, embedded into a web page
– To be covered later
Simple Dialogs
• Example1: HelloWorld.java
• Example2: Addition.java
• Example3: Choice.java
Example
Simple GUI program [Hallo world]
• Example1: HelloWorld.java
Java Swing
The remaining of our class Lectures is all about
Java Swing toolkit
Do not miss any of the class
Get prepared
DEDICATED
JOKE
“I will do later…..”
TIME
THANK YOU~~~