SlideShare a Scribd company logo
Presentation
ObjectOriented
Programming
(OOP)
Presented By :
“Abu Sufyan”
Presented To :
“Mam Qoseen”
PAGE 1
COURSE
OUTLINE
Graphical user interface Components
Introduction to Swing, Control button, Labels, Text
fields, Text area, Checkbox and Radio buttons.
Event handling, The delegation event model (events,
events source and event listener).
Introduction to AWT, AWT classes.
Creating a Window program working with graphics.
Layout manager and manuals control fundamentals.
PAGE 2
CUI/CLI (Character/Console User Interface)
 A command-line interface (CLI) is a text-based
user interface (UI) used to run programs,
manage computer files and interact with the
computer. Command-line interfaces are also
called command-line user interfaces, console
user interfaces, and character user interfaces.
 It is CUI programming in which we can write a
program in one portion and on another side
we obtain the result of the program.
 We get results after using only text
components.
PAGE 3
GUI (Applications )
 It is a screen or interface which interacts with the user
in the sense of a graph.
 This interface is called Graphic User Interface.
 Here we perform interaction by using visual
components.
Java provides to set of (APIs) Application Programming
interfaces which are given below.
Basically, APIs are the set/ bunches of predefined Classes
in Java library.
PAGE 4
 Java Application
 APIs
AWT SWING
APIs
Graphical user interface
 A GUI (Graphical User
Interface) is a type of user
interface that allows users to
interact with a program using
graphical elements such as
buttons, menus, and text boxes. Its
purpose in programming is to
make it easier for users to interact
with a program by providing a
visual representation of the
program's features and functions.
GUIs can enhance the user
experience by providing a more
intuitive and visually appealing
way to interact with a program, as
compared to text-based interfaces
that require users to enter
commands via a command-line
interface.
Introduction to Swing :
 Swing is a set of GUI Swing
controls are (graphical user
interface) lightweight and
provide components that are
used to consistent look and feel
create desktop applications in
across different platforms. Java.
It is part of the Java They are
also highly Foundation Classes
(JFC) and customizable, allowing
provides a rich set of controls
developers to create that can be
used to build unique and
visually complex user interfaces
appealing interfaces.
PAGE 5
AWT(Abstract Window toolkit)
Basically, AWT is a package of predefined classes in the Java library.
It consists of 12 packages which 2 packages are mostly used in the Java library.
1. Java.Awt Package
This package has furthermore classes which are given below.
GUI_ Component Classes :
It consists of (buttons, labels, a text area, a checkbox, and radio buttons)
GUI_ container Classes :
It consists of (a frame, panel, dialog, window, and scroll panel)
GUI_ Layout Manager :
It consists of (a flow layout, a border layout, and a grid layout)
Custom Graphic Classes :
It consists of ( Graph, color and font)
PAGE 6
1.Java.awt
Package 2.Java.awt
event package
 1. Buttons
2. Text Area
3. Labels
4. Checkboxes
5. Radio Buttons
PAE 7
Components of GUI
 Control
Buttons
“A control button is a control that appears on a form as a
button that users can click to display a menu of commands or
call a dialog.”
“Buttons can be used to initiate an action or trigger an event. For
example, a button labeled "Save" can be used to save data entered into
a form, or a button labeled "Exit" can be used to close a window or quit
the program attribution.”
Control key :
 Ctrl stands for "Control Key". It was originally used to send
control characters to terminals.
Type Of Control Button :
 Print Screen, Scroll Lock, Pause, Break, Insert, Home, Page
Up, Delete, End, and Page Down are all examples of control
keys.
Examples :
 The most frequently used control keys are Ctrl, Alt, the
Windows logo key, and Esc. Function keys. The function keys
are used to perform specific tasks.
PAGE 8
Control Buttons
Constructor Description
JButton() It creates a button with no text and
icon.
JButton(String s) It creates a button with the
specified text.
JButton(Icon i) It creates a button with the
specified icon object.
Methods Description
void setText(String s) It is used to set specified text on
button
String getText() It is used to return the text of the
button.
void setEnabled(boolean b) It is used to enable or disable the
button.
void setIcon(Icon b) It is used to set the specified Icon
on the button.
Icon getIcon() It is used to get the Icon of the
button.
void setMnemonic(int a) It is used to set the mnemonic on
the button.
void
addActionListener(ActionListener
a)
It is used to add the action
listener to this object.
PAGE 9
Button Programs
import javax.swing.*;
public class ButtonExample {
public static void main(String[] args) {
JFrame f=new JFrame("Button Example");
JButton b=new JButton("Click Here");
b.setBounds(50,100,95,30);
f.add(b);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
}
PAGE 10
Button
Programs
 import javax.swing.*;
 public class ButtonExample{
 ButtonExample(){
 JFrame f=new JFrame("Button Example");
 JButton b=new JButton(new ImageIcon("D:icon.png"
));
 b.setBounds(100,100,100, 40);
 f.add(b);
 f.setSize(300,400);
 f.setLayout(null);
 f.setVisible(true);
 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }
 public static void main(String[] args) {
 new ButtonExample();
 }
 }
PAGE 11
 Text Area
PAGE 12
● A text area is a multi-line text input control that allows
users to enter and edit large amounts of text. It is
commonly used for tasks such as entering comments,
descriptions, or notes.
● In Java, text areas can be created using the Text Area
class. Text areas can be customized by setting
properties such as font, color, size, and border. They
can also be made read-only or disabled if needed.
 Labels
 A label is a graphical control element
which displays text on a form. It is usually
a static control; having no interactivity. A
label is generally used to ...
 • Windows Forms Label controls are used
to display text or images that cannot be
edited by the user. They are used to
identify objects on a form—to provide a
description of what a certain control will
do if clicked, for example, or to display
information in response to a runtime
event or process in your application.
PAGE 13
 Checkbox
 A checkbox is a control that allows users
to select one or more options from a list.
It is commonly used for tasks such as
selecting preferences or features in an
application.
 In Java, checkboxes can be created using
the Checkbox class. Checkboxes can be
customized by setting properties such as
font, color, size, and border. They can
also be grouped together using a Button
Group to ensure that only one option is
selected at a time.
PAGE 14
Radio Buttons
 A radio button is a control that allows
users to select one option from a list. It is
commonly used for tasks such as
selecting a gender or a payment method.
 In Java, radio buttons can be created
using the Radio Button class. Radio
buttons can be customized by setting
properties such as font, color, size, and
border. They can also be grouped
together using a Button Group to ensure
that only one option is selected at a time.
PAGE 15
Introduction
To AWT
 AWT (Abstract Window Toolkit) is an API to develop
Graphical User Interface (GUI) or Windows-based
applications in Java.
 AWT provides various components like buttons, labels,
checkboxes, etc. used as objects inside a Java Program.
AWT components use the resources of the operating
system, i.e., they are platform-dependent, which means,
the component's view can be changed according to the
view of the operating system. The classes for AWT are
provided by Java. Awt package for various AWT
components.
PAGE 16
AWT Classes
Component Class :
The component class stands at the top of the AWT hierarchy, is an
abstract class that contains all the properties of the component visible on
the screen. The Component object contains information about the
currently selected foreground and background color. It also has
information about the currently selected text color.
Container :
The container is a component that contains other components like
buttons, text fields, labels, etc. However, it is a subclass of the
Component class.
Panel :
The panel can be defined as a container that can be used to hold other
components. However, it doesn't contain the title bar, menu bar, or
border.
Window
A window can be defined as a container that doesn't contain any border
or menu bar. It creates a top-level view. However, we must have a frame,
dialog, or another window for creating a window.
Frame :
The frame is a subclass of Window. It can be defined as a container with
components like buttons, text fields, labels, etc. In other words, AWT
applications are mostly created using frame containers.
PAGE 17
Event Handling
 Event handling is the process of responding
to user actions or system-generated events
in a GUI application. In GUI programming,
events can include actions such as button
clicks, menu selections, key presses, mouse
movements, and window resize events,
among others. Event handling enables
programmers to write code that responds
to these events and updates the
application's user interface accordingly.
 In Java, Event Handling is achieved through
the use of event listeners and event
sources.
 An event listener is an object that is
registered to receive notifications when a
particular event occurs.
 Event Sources contain information about
the event, such as which component
generated it and what type of event it is.
PAGE 18
EventListener
 To use event handling in a GUI program, the programmer
typically creates an event listener class that implements
one or more listener interfaces. For example, to handle
button clicks, the programmer can create a class that
implements the Action Listener interface. This class can
then be registered with a button component using the add
Action Listener method, which tells the button to notify the
listener when it is clicked.
PAGE 19
EventSource
 When the button is clicked, it generates an Action Event
source and sends it to the Action Listener object that is
registered to receive notifications. The Action Listener
object can then use the information in the Action Event
source to perform some action, such as updating a text field
or launching a new window.
PAGE 20
Layouts
 Layouts in a GUI are used to arrange components (such as buttons, text boxes, and labels) on a
window or container. The layout manager is responsible for determining the size and position of
each component based on the layout rules that have been set.
PAGE 21
Creating
Window
Programs
 import java.awt.*;
 import java.awt.event.*;
 import java.applet.*;
public class Cal extends Applet implements ActionListener
{ String msg=" ";
int v1,v2,result;
TextField t1;
Button b[]=new Button[10];
Button add,sub,mul,div,clear,mod,EQ;
char OP;
public void init(){ Color k=new Color(120,89,90);
setBackground(k);
t1=new TextField(100);
GridLayout gl=new GridLayout(4,5);
setLayout(gl);
for(int i=0;
PAGE 22
Layout
Managers
 There are several types of layout managers in Java,
each with its own set of rules for arranging
components:
 Flow Layout: Components are arranged in a row, from
left to right, until the row is filled, and then a new row
is started.
 Border Layout: Components are arranged in regions:
North, South, East, West, and Center. Each region can
contain only one component, and the size of the
component is determined by the size of the region.
 Grid Layout: Components are arranged in a grid, with a
fixed number of rows and columns. Each cell in the grid
can contain only one component, and all cells are the
same size.
 Box Layout: Components are arranged in a single row
or column, and can be aligned either horizontally or
vertically.
 Grid Bag Layout: Components are arranged in a grid
but with more flexibility than the Grid Layout. Each
component can span multiple rows and columns, and
the size of each cell can be adjusted.
PAGE 23
PAGE 24
Do you have any questions?
“This presentation was created by “Abu Sufyan”,
Sufisaab098@gmail.com

More Related Content

Similar to GUI.pdf

Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
renuka gavli
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
Adil Mehmoood
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)
Bilal Amjad
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
suraj pandey
 
GUI_part_1.pptx
GUI_part_1.pptxGUI_part_1.pptx
GUI_part_1.pptx
Parasuraman43
 
UNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdfUNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdf
PriyanshiPrajapati27
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
Hemo Chella
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
Hemo Chella
 
AWT information
AWT informationAWT information
AWT information
Unit Nexus Pvt. Ltd.
 
Graphical User Interface (GUI)
Graphical User Interface (GUI)Graphical User Interface (GUI)
Graphical User Interface (GUI)
Estiak Khan
 
Programming 2: Java Midterm Week Twelve.
Programming 2: Java Midterm Week Twelve.Programming 2: Java Midterm Week Twelve.
Programming 2: Java Midterm Week Twelve.
HyunJeiThaddeus
 
JAVA (UNIT 5)
JAVA (UNIT 5)JAVA (UNIT 5)
JAVA (UNIT 5)
SURBHI SAROHA
 
Graphical User Interface
Graphical User Interface Graphical User Interface
Graphical User Interface
Bivek Pakuwal
 
Advanced java lab swing mvc awt
Advanced java lab swing mvc awtAdvanced java lab swing mvc awt
Advanced java lab swing mvc awt
vishal choudhary
 
Gui Layout Presentation
Gui Layout PresentationGui Layout Presentation
Gui Layout Presentationtrangy
 
Slot04 creating gui
Slot04 creating guiSlot04 creating gui
Slot04 creating gui
Viên Mai
 
The Use of Java Swing’s Components to Develop a Widget
The Use of Java Swing’s Components to Develop a WidgetThe Use of Java Swing’s Components to Develop a Widget
The Use of Java Swing’s Components to Develop a Widget
Waqas Tariq
 

Similar to GUI.pdf (20)

Java Land F
Java Land FJava Land F
Java Land F
 
Java Land F
Java Land FJava Land F
Java Land F
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
 
GUI_part_1.pptx
GUI_part_1.pptxGUI_part_1.pptx
GUI_part_1.pptx
 
UNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdfUNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdf
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
 
Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
 
AWT information
AWT informationAWT information
AWT information
 
Graphical User Interface (GUI)
Graphical User Interface (GUI)Graphical User Interface (GUI)
Graphical User Interface (GUI)
 
Programming 2: Java Midterm Week Twelve.
Programming 2: Java Midterm Week Twelve.Programming 2: Java Midterm Week Twelve.
Programming 2: Java Midterm Week Twelve.
 
JAVA (UNIT 5)
JAVA (UNIT 5)JAVA (UNIT 5)
JAVA (UNIT 5)
 
Graphical User Interface
Graphical User Interface Graphical User Interface
Graphical User Interface
 
Advanced java lab swing mvc awt
Advanced java lab swing mvc awtAdvanced java lab swing mvc awt
Advanced java lab swing mvc awt
 
Gui Layout Presentation
Gui Layout PresentationGui Layout Presentation
Gui Layout Presentation
 
Slot04 creating gui
Slot04 creating guiSlot04 creating gui
Slot04 creating gui
 
The Use of Java Swing’s Components to Develop a Widget
The Use of Java Swing’s Components to Develop a WidgetThe Use of Java Swing’s Components to Develop a Widget
The Use of Java Swing’s Components to Develop a Widget
 

Recently uploaded

Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 

Recently uploaded (20)

Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 

GUI.pdf

  • 1. Presentation ObjectOriented Programming (OOP) Presented By : “Abu Sufyan” Presented To : “Mam Qoseen” PAGE 1
  • 2. COURSE OUTLINE Graphical user interface Components Introduction to Swing, Control button, Labels, Text fields, Text area, Checkbox and Radio buttons. Event handling, The delegation event model (events, events source and event listener). Introduction to AWT, AWT classes. Creating a Window program working with graphics. Layout manager and manuals control fundamentals. PAGE 2
  • 3. CUI/CLI (Character/Console User Interface)  A command-line interface (CLI) is a text-based user interface (UI) used to run programs, manage computer files and interact with the computer. Command-line interfaces are also called command-line user interfaces, console user interfaces, and character user interfaces.  It is CUI programming in which we can write a program in one portion and on another side we obtain the result of the program.  We get results after using only text components. PAGE 3
  • 4. GUI (Applications )  It is a screen or interface which interacts with the user in the sense of a graph.  This interface is called Graphic User Interface.  Here we perform interaction by using visual components. Java provides to set of (APIs) Application Programming interfaces which are given below. Basically, APIs are the set/ bunches of predefined Classes in Java library. PAGE 4  Java Application  APIs AWT SWING APIs
  • 5. Graphical user interface  A GUI (Graphical User Interface) is a type of user interface that allows users to interact with a program using graphical elements such as buttons, menus, and text boxes. Its purpose in programming is to make it easier for users to interact with a program by providing a visual representation of the program's features and functions. GUIs can enhance the user experience by providing a more intuitive and visually appealing way to interact with a program, as compared to text-based interfaces that require users to enter commands via a command-line interface. Introduction to Swing :  Swing is a set of GUI Swing controls are (graphical user interface) lightweight and provide components that are used to consistent look and feel create desktop applications in across different platforms. Java. It is part of the Java They are also highly Foundation Classes (JFC) and customizable, allowing provides a rich set of controls developers to create that can be used to build unique and visually complex user interfaces appealing interfaces. PAGE 5
  • 6. AWT(Abstract Window toolkit) Basically, AWT is a package of predefined classes in the Java library. It consists of 12 packages which 2 packages are mostly used in the Java library. 1. Java.Awt Package This package has furthermore classes which are given below. GUI_ Component Classes : It consists of (buttons, labels, a text area, a checkbox, and radio buttons) GUI_ container Classes : It consists of (a frame, panel, dialog, window, and scroll panel) GUI_ Layout Manager : It consists of (a flow layout, a border layout, and a grid layout) Custom Graphic Classes : It consists of ( Graph, color and font) PAGE 6 1.Java.awt Package 2.Java.awt event package
  • 7.  1. Buttons 2. Text Area 3. Labels 4. Checkboxes 5. Radio Buttons PAE 7 Components of GUI
  • 8.  Control Buttons “A control button is a control that appears on a form as a button that users can click to display a menu of commands or call a dialog.” “Buttons can be used to initiate an action or trigger an event. For example, a button labeled "Save" can be used to save data entered into a form, or a button labeled "Exit" can be used to close a window or quit the program attribution.” Control key :  Ctrl stands for "Control Key". It was originally used to send control characters to terminals. Type Of Control Button :  Print Screen, Scroll Lock, Pause, Break, Insert, Home, Page Up, Delete, End, and Page Down are all examples of control keys. Examples :  The most frequently used control keys are Ctrl, Alt, the Windows logo key, and Esc. Function keys. The function keys are used to perform specific tasks. PAGE 8
  • 9. Control Buttons Constructor Description JButton() It creates a button with no text and icon. JButton(String s) It creates a button with the specified text. JButton(Icon i) It creates a button with the specified icon object. Methods Description void setText(String s) It is used to set specified text on button String getText() It is used to return the text of the button. void setEnabled(boolean b) It is used to enable or disable the button. void setIcon(Icon b) It is used to set the specified Icon on the button. Icon getIcon() It is used to get the Icon of the button. void setMnemonic(int a) It is used to set the mnemonic on the button. void addActionListener(ActionListener a) It is used to add the action listener to this object. PAGE 9
  • 10. Button Programs import javax.swing.*; public class ButtonExample { public static void main(String[] args) { JFrame f=new JFrame("Button Example"); JButton b=new JButton("Click Here"); b.setBounds(50,100,95,30); f.add(b); f.setSize(400,400); f.setLayout(null); f.setVisible(true); } } PAGE 10
  • 11. Button Programs  import javax.swing.*;  public class ButtonExample{  ButtonExample(){  JFrame f=new JFrame("Button Example");  JButton b=new JButton(new ImageIcon("D:icon.png" ));  b.setBounds(100,100,100, 40);  f.add(b);  f.setSize(300,400);  f.setLayout(null);  f.setVisible(true);  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  }  public static void main(String[] args) {  new ButtonExample();  }  } PAGE 11
  • 12.  Text Area PAGE 12 ● A text area is a multi-line text input control that allows users to enter and edit large amounts of text. It is commonly used for tasks such as entering comments, descriptions, or notes. ● In Java, text areas can be created using the Text Area class. Text areas can be customized by setting properties such as font, color, size, and border. They can also be made read-only or disabled if needed.
  • 13.  Labels  A label is a graphical control element which displays text on a form. It is usually a static control; having no interactivity. A label is generally used to ...  • Windows Forms Label controls are used to display text or images that cannot be edited by the user. They are used to identify objects on a form—to provide a description of what a certain control will do if clicked, for example, or to display information in response to a runtime event or process in your application. PAGE 13
  • 14.  Checkbox  A checkbox is a control that allows users to select one or more options from a list. It is commonly used for tasks such as selecting preferences or features in an application.  In Java, checkboxes can be created using the Checkbox class. Checkboxes can be customized by setting properties such as font, color, size, and border. They can also be grouped together using a Button Group to ensure that only one option is selected at a time. PAGE 14
  • 15. Radio Buttons  A radio button is a control that allows users to select one option from a list. It is commonly used for tasks such as selecting a gender or a payment method.  In Java, radio buttons can be created using the Radio Button class. Radio buttons can be customized by setting properties such as font, color, size, and border. They can also be grouped together using a Button Group to ensure that only one option is selected at a time. PAGE 15
  • 16. Introduction To AWT  AWT (Abstract Window Toolkit) is an API to develop Graphical User Interface (GUI) or Windows-based applications in Java.  AWT provides various components like buttons, labels, checkboxes, etc. used as objects inside a Java Program. AWT components use the resources of the operating system, i.e., they are platform-dependent, which means, the component's view can be changed according to the view of the operating system. The classes for AWT are provided by Java. Awt package for various AWT components. PAGE 16
  • 17. AWT Classes Component Class : The component class stands at the top of the AWT hierarchy, is an abstract class that contains all the properties of the component visible on the screen. The Component object contains information about the currently selected foreground and background color. It also has information about the currently selected text color. Container : The container is a component that contains other components like buttons, text fields, labels, etc. However, it is a subclass of the Component class. Panel : The panel can be defined as a container that can be used to hold other components. However, it doesn't contain the title bar, menu bar, or border. Window A window can be defined as a container that doesn't contain any border or menu bar. It creates a top-level view. However, we must have a frame, dialog, or another window for creating a window. Frame : The frame is a subclass of Window. It can be defined as a container with components like buttons, text fields, labels, etc. In other words, AWT applications are mostly created using frame containers. PAGE 17
  • 18. Event Handling  Event handling is the process of responding to user actions or system-generated events in a GUI application. In GUI programming, events can include actions such as button clicks, menu selections, key presses, mouse movements, and window resize events, among others. Event handling enables programmers to write code that responds to these events and updates the application's user interface accordingly.  In Java, Event Handling is achieved through the use of event listeners and event sources.  An event listener is an object that is registered to receive notifications when a particular event occurs.  Event Sources contain information about the event, such as which component generated it and what type of event it is. PAGE 18
  • 19. EventListener  To use event handling in a GUI program, the programmer typically creates an event listener class that implements one or more listener interfaces. For example, to handle button clicks, the programmer can create a class that implements the Action Listener interface. This class can then be registered with a button component using the add Action Listener method, which tells the button to notify the listener when it is clicked. PAGE 19
  • 20. EventSource  When the button is clicked, it generates an Action Event source and sends it to the Action Listener object that is registered to receive notifications. The Action Listener object can then use the information in the Action Event source to perform some action, such as updating a text field or launching a new window. PAGE 20
  • 21. Layouts  Layouts in a GUI are used to arrange components (such as buttons, text boxes, and labels) on a window or container. The layout manager is responsible for determining the size and position of each component based on the layout rules that have been set. PAGE 21
  • 22. Creating Window Programs  import java.awt.*;  import java.awt.event.*;  import java.applet.*; public class Cal extends Applet implements ActionListener { String msg=" "; int v1,v2,result; TextField t1; Button b[]=new Button[10]; Button add,sub,mul,div,clear,mod,EQ; char OP; public void init(){ Color k=new Color(120,89,90); setBackground(k); t1=new TextField(100); GridLayout gl=new GridLayout(4,5); setLayout(gl); for(int i=0; PAGE 22
  • 23. Layout Managers  There are several types of layout managers in Java, each with its own set of rules for arranging components:  Flow Layout: Components are arranged in a row, from left to right, until the row is filled, and then a new row is started.  Border Layout: Components are arranged in regions: North, South, East, West, and Center. Each region can contain only one component, and the size of the component is determined by the size of the region.  Grid Layout: Components are arranged in a grid, with a fixed number of rows and columns. Each cell in the grid can contain only one component, and all cells are the same size.  Box Layout: Components are arranged in a single row or column, and can be aligned either horizontally or vertically.  Grid Bag Layout: Components are arranged in a grid but with more flexibility than the Grid Layout. Each component can span multiple rows and columns, and the size of each cell can be adjusted. PAGE 23
  • 24. PAGE 24 Do you have any questions? “This presentation was created by “Abu Sufyan”, Sufisaab098@gmail.com