You are on page 1of 16

Java Programming

with GUI
Prepared by:
Efril Datulaita
Sunshine Agos
Angelic Nillo

Java Programming
with GUI

What is GUI
Basic GUI objects
Abstract Window Toolkit
Swing
Swing Components

WHAT IS GUI ?
Pronounced as (goo-ee)
GUI stands for Graphical User
Interface
Displays a graphical images(text
boxes, buttons, and icons) on the
screen that the user can interact or
manipulate with devices such as
mouse.

WHAT IS GUI ?
A GUI obtains information from the
user and gives it to the program for
processing. When the program is
finished processing information, the
GUI gives the result to the user,
usually in some sort of window.
A GUI is built by putting
components into containers.

BASIC GUI OBJECTS

WINDO
W

MEN
U
BUTTON

LABE
L
TEXT
BOX

BASIC GUI OBJECTS


WINDOW
Awindowis a (usually) rectangular portion

of the display on a computer monitor that


presents its contents (e.g., the contents of
a directory, a text file or an image)
seemingly independently of the rest of the
screen.

LABEL

Displays unselectable texts or images

BASIC GUI OBJECTS


Menu
A list of alternatives offered to the user,

usually by offering a list of names.


provides a space-saving way to let the user
choose one of several options.

Button
A button that is simply something that

looks like a button to be pushed and that


typically has a label.

BASIC GUI OBJECTS


Text Box
A text box's purpose is to allow the user to

input text information to be used by the


program.
Display selectable text and, optionally,
allow the user to edit the text.

ABSTRACT WINDOW
TOOLKIT
Abstract Window Toolkit (AWT) is a
collection of graphical user interface
(GUI) components (widgets) and
other related services required for
GUI programming in Java.
AWT was platform dependent, which
means a program written in AWT
behaves differently in different
platforms.

ABSTRACT WINDOW
TOOLKIT
AWT components require the
resources of the operating system
on which they are installed
They are called heavyweight
components.

ABSTRACT WINDOW
TOOLKIT

Basic objects derived from Components in


package java.awt :
Button
Used to trigger actions and other events.
Button btn1=new Button();

Checkbox
Item that can be in either an on(true) or
off(false) state.
Checkbox box = new Checkbox();

Label
Used to show the text or string in an application
and label never perform any type of action.
Label lab1 = new Label():

ABSTRACT WINDOW
TOOLKIT
List
Presents the user with a scrolling list of text items.
Listlists=newList(5);

Scrollbar
Provides a convenient means for allowing a user to
select from a range of values.
Scrollbar sb = new Scrollbar();

TextArea
A text container component, contains plain text.
TextArea inputArea = new TextArea();

TextField
A text container component, contains single line and
limited text information.
TextField nf = new TextField();

SWING
A swing application developed on
one platform behaves the same on
any other platform in which Java is
installed. Extends capabilities in
Abstract Window Toolkit (AWT)
Swing gives far more options for
everything (buttons with pictures on
them, etc.)

SWING COMPONENTS
Swing components are platform
independent, requiring only the Java
runtime system to function.
They are called lightweight
components.
Names of the Swing GUI
components are almost similar to
that of AWT

SWING COMPONENTS

Basic objects that mirror the AWT


components
JButton
Jbutton btn = new Jbutton();

JCheckBox
cb=new JCheckBox();

JLabel
JLabel jlb = new JLabel();

SWING COMPONENTS
Jlist
JList dataList = new JList(data);

JScrollbar
JScrollPane scrollPane = new JScrollPane();

JTextArea
JTextArea resultArea = new JTextArea();

JTextField
JTextField txt = new JTextField();