SlideShare a Scribd company logo
GUI in Java
By
Sharmilee
9894303344
Java Trainer
Mazenet Solution
Objectives
• GUI Introduction
• Applet Programming
• Applet Lifecycle
• AWT
• SWING
• Layouts
• Event Handling
Graphical User Interface
Java- GUI- Mazenet solution
Applet Programming
Introduction
• Applet is a special type of program that is
embedded in the webpage to generate the
dynamic content.
• It runs inside the browser and works at
client side.
Advantage
• It works at client side so less response time.
• Secured
• It can be executed by browsers running
under many platforms, including Linux,
Windows, Mac Os etc.
Applet viewer
Hierarchy of Applet
Lifecycle methods
• java.applet.Applet
 public void init()
 public void start()
 public void stop()
 public void destroy()
• java.awt.Component
 public void paint()
Java AWT
Abstract Window Toolkit (AWT)
• It is platform-dependent windowing,
graphics, and user-interface widget toolkit
preceding Swing.
• AWT is part of the Java Foundation Classes
(JFC)
• the standard API for providing a graphical
user interface (GUI) for a Java program.
Java- GUI- Mazenet solution
AWT Hierarchy
Creating an awt
• To create awt example, we have two
methods
– By extending frame class(Inheritance)
– By creating the object of frame class
(association)
Container
• It is a component in AWT
• It contain another components like buttons,
textfields, labels etc.
• The classes that extends Container class are
known as container such as Frame, Dialog
and Panel.
Java- GUI- Mazenet solution
Panel
• The Panel is the container that doesn't
contain title bar and menu bars.
• It can have other components like button,
textfield etc.
Java- GUI- Mazenet solution
Frame
• Frame is the container that contain title bar
and can have menu bars.
• It can have other components like button,
textfield etc.
Java- GUI- Mazenet solution
AWT to Swing
• AWT: Abstract Windowing Toolkit
• import java.awt.*
• Swing:
• import javax.swing.*
Swing
Introduction to Swing
• It is used to create window-based
applications.
• It is built on the top of AWT API and
entirely written in java.
• Swing provides platform-independent and
lightweight components.
Swing classes
Using a GUI Component
1. Create it
• Instantiate object: b = new JButton(“press me”);
2. Configure it
• Properties: b.text = “press me”; [avoided in
java]
• Methods: b.setText(“press me”);
3. Add it
• panel.add(b);
4. Listen to it
• Events: Listeners
JButton
Code
JFrame f = new JFrame(“title”);
JPanel p = new JPanel( );
JButton b = new JButton(“press me”);
p.add(b); // add button to panel
f.setContentPane(p); // add panel to frame
f.show();
press me
Application Code
import javax.swing.*;
class hello {
public static void main(String[] args){
JFrame f = new JFrame(“title”);
JPanel p = new JPanel();
JButton b = new JButton(“press me”);
p.add(b); // add button to panel
f.setContentPane(p); // add panel to frame
f.show();
}
}
press me
Difference between AWT & Swing
Sno AWT SWING
1 Platform dependent Platform Independent
2 Heavyweight components Light weight components
3 Doesn’t support pluggable look
and feel
Supports pluggable look and feel
4 Less components than swing More powerful components
5 Doesn’t follow MVC Follows MVC
Layout
Layout Manager
Left to right,
Top to bottom
c
n
s
ew
FlowLayout GridLayout
BorderLayout
none,
programmer
sets x,y,w,h
null
One at a time
CardLayout GridBagLayout
JButton
Event Handling
• Changing the state of an object is known as
an event.
• For example,
– click on button,
– dragging mouse etc.
• The java.awt.event package provides many
event classes and Listener interfaces for
event handling.
Steps to perform Event Handling
1. Implement the Listener interface and overrides
its methods
2. Register the component with the Listener
Thank You!!!

More Related Content

PPT
Java: GUI
PPTX
GUI components in Java
PPTX
GUI Programming with Java
PPT
GUI Programming In Java
PPT
Swing and AWT in java
PDF
PPT
Awt and swing in java
Java: GUI
GUI components in Java
GUI Programming with Java
GUI Programming In Java
Swing and AWT in java
Awt and swing in java

What's hot (20)

PPT
java2 swing
PPTX
Complete java swing
PPT
Swing and Graphical User Interface in Java
PPT
Graphical User Interface (GUI) - 1
PDF
The AWT and Swing
PPTX
PPTX
Chapter 1 swings
PPTX
GUI programming
PPT
Java Swing
PPT
Java swing
PPT
java swing
PPTX
Java swing
PPTX
tL19 awt
PPTX
GUI Programming in JAVA (Using Netbeans) - A Review
PPTX
PPT
Java Swing JFC
PPT
28 awt
PPT
Basic using of Swing in Java
PDF
04b swing tutorial
java2 swing
Complete java swing
Swing and Graphical User Interface in Java
Graphical User Interface (GUI) - 1
The AWT and Swing
Chapter 1 swings
GUI programming
Java Swing
Java swing
java swing
Java swing
tL19 awt
GUI Programming in JAVA (Using Netbeans) - A Review
Java Swing JFC
28 awt
Basic using of Swing in Java
04b swing tutorial
Ad

Viewers also liked (20)

PPT
.Net- Introduction to Linq & practical session on ADO & ASP.NET- Mazenet solu...
PPTX
Dotnet- An overview of ASP.NET & ADO.NET- Mazenet solution
PPT
Testing- Fundamentals of Testing-Mazenet solution
PPT
Oracle- Introduction to Sql commands- Mazenet solution
PPT
Oracle-L11 using Oracle flashback technology-Mazenet solution
PDF
Cehv8 - references
PPTX
Rhel6 vs rhel7
PDF
Cehv8 - Module 20: penetration testing
PPT
Software Testing- Principles of testing- Mazenet Solution
PDF
Cehv8 Labs - Module17: Evading IDS, Firewalls and Honeypots.
PPT
Static testing techniques
PPT
Java - Servlet - Mazenet Solution
PPT
Software Testing - Tool support for testing (CAST) - Mazenet Solution
PPTX
Java- Updates in java8-Mazenet solution
PPT
Java- Java tech overview- Mazenet solution
PDF
Cehv8 Labs - Module15: Hacking Wireless Networks.
PDF
Install and Configure RSyslog – CentOS 7 / RHEL 7
PDF
Cehv8 Labs - Module07: Viruses and Worms.
PPTX
Ethical Hacking
PPTX
Java- JDBC- Mazenet Solution
.Net- Introduction to Linq & practical session on ADO & ASP.NET- Mazenet solu...
Dotnet- An overview of ASP.NET & ADO.NET- Mazenet solution
Testing- Fundamentals of Testing-Mazenet solution
Oracle- Introduction to Sql commands- Mazenet solution
Oracle-L11 using Oracle flashback technology-Mazenet solution
Cehv8 - references
Rhel6 vs rhel7
Cehv8 - Module 20: penetration testing
Software Testing- Principles of testing- Mazenet Solution
Cehv8 Labs - Module17: Evading IDS, Firewalls and Honeypots.
Static testing techniques
Java - Servlet - Mazenet Solution
Software Testing - Tool support for testing (CAST) - Mazenet Solution
Java- Updates in java8-Mazenet solution
Java- Java tech overview- Mazenet solution
Cehv8 Labs - Module15: Hacking Wireless Networks.
Install and Configure RSyslog – CentOS 7 / RHEL 7
Cehv8 Labs - Module07: Viruses and Worms.
Ethical Hacking
Java- JDBC- Mazenet Solution
Ad

Similar to Java- GUI- Mazenet solution (20)

PPTX
This presentation is about swing concept in python
PDF
GUI.pdf
PPTX
JAVA SWING PPT FOR PROGRAMMING AND CODING
PPT
2.swing.ppt advance java programming 3rd year
PPTX
Awt, Swing, Layout managers
PPTX
Swing !!! y shikhar!!
PPT
Java Swing Handson Session (1).ppt
PPTX
SWING-AWT_Overview of Swing and AWT.pptx
PPT
25 awt
PPT
Graphic User Interface (GUI) Presentation
PPTX
MODULE 5.pptx gui programming and applets
PPTX
UNIT 2 SWIGS for java programing by .pptx
PDF
java presentation on Swings chapter java presentation on Swings
PDF
Swingpre 150616004959-lva1-app6892
PPT
Java lecture
PPTX
Computer Programming NC III - Java Swing.pptx
PDF
Ajp notes-chapter-02
PDF
JAVA GUI PART I
PPT
14a-gui.ppt
DOC
java swing notes in easy manner for UG students
This presentation is about swing concept in python
GUI.pdf
JAVA SWING PPT FOR PROGRAMMING AND CODING
2.swing.ppt advance java programming 3rd year
Awt, Swing, Layout managers
Swing !!! y shikhar!!
Java Swing Handson Session (1).ppt
SWING-AWT_Overview of Swing and AWT.pptx
25 awt
Graphic User Interface (GUI) Presentation
MODULE 5.pptx gui programming and applets
UNIT 2 SWIGS for java programing by .pptx
java presentation on Swings chapter java presentation on Swings
Swingpre 150616004959-lva1-app6892
Java lecture
Computer Programming NC III - Java Swing.pptx
Ajp notes-chapter-02
JAVA GUI PART I
14a-gui.ppt
java swing notes in easy manner for UG students

More from Mazenetsolution (15)

PPTX
Tally Auto E-mail Module | Mazenet Technologies
PPTX
Tally Auto SMS Module| Mazenet Technologies
PPTX
Tally auto synchronization
PPTX
Print barcode using voucher- Mazenettechnologies
PPTX
Copy user list | Tally | Tally Software | Accounting Software | Mazenet
PPTX
Auto synchronization | Tally Software | Mazenet Technologies
PPTX
Auto backup | Tally Coimbatore | Tally Software
PPTX
Mazenet Technologies-Tally
PPTX
Android - Intents - Mazenet Solution
PPT
Software Testing - Test management - Mazenet Solution
PPTX
Red Hat - LVM - Mazenet Solution
PPT
PHP - Introduction to PHP - Mazenet Solution
PPTX
Process management in linux
PPT
Software Testing-Dynamic testing technique-Mazenet solution
PPT
Red Hat Enterprise Linux 7
Tally Auto E-mail Module | Mazenet Technologies
Tally Auto SMS Module| Mazenet Technologies
Tally auto synchronization
Print barcode using voucher- Mazenettechnologies
Copy user list | Tally | Tally Software | Accounting Software | Mazenet
Auto synchronization | Tally Software | Mazenet Technologies
Auto backup | Tally Coimbatore | Tally Software
Mazenet Technologies-Tally
Android - Intents - Mazenet Solution
Software Testing - Test management - Mazenet Solution
Red Hat - LVM - Mazenet Solution
PHP - Introduction to PHP - Mazenet Solution
Process management in linux
Software Testing-Dynamic testing technique-Mazenet solution
Red Hat Enterprise Linux 7

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Cell Types and Its function , kingdom of life
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Pharma ospi slides which help in ospi learning
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Pre independence Education in Inndia.pdf
PDF
Sports Quiz easy sports quiz sports quiz
Microbial diseases, their pathogenesis and prophylaxis
Abdominal Access Techniques with Prof. Dr. R K Mishra
Cell Types and Its function , kingdom of life
102 student loan defaulters named and shamed – Is someone you know on the list?
Pharma ospi slides which help in ospi learning
O5-L3 Freight Transport Ops (International) V1.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Anesthesia in Laparoscopic Surgery in India
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
VCE English Exam - Section C Student Revision Booklet
Supply Chain Operations Speaking Notes -ICLT Program
Microbial disease of the cardiovascular and lymphatic systems
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Renaissance Architecture: A Journey from Faith to Humanism
Pre independence Education in Inndia.pdf
Sports Quiz easy sports quiz sports quiz

Java- GUI- Mazenet solution

  • 1. GUI in Java By Sharmilee 9894303344 Java Trainer Mazenet Solution
  • 2. Objectives • GUI Introduction • Applet Programming • Applet Lifecycle • AWT • SWING • Layouts • Event Handling
  • 6. Introduction • Applet is a special type of program that is embedded in the webpage to generate the dynamic content. • It runs inside the browser and works at client side.
  • 7. Advantage • It works at client side so less response time. • Secured • It can be executed by browsers running under many platforms, including Linux, Windows, Mac Os etc.
  • 10. Lifecycle methods • java.applet.Applet  public void init()  public void start()  public void stop()  public void destroy() • java.awt.Component  public void paint()
  • 12. Abstract Window Toolkit (AWT) • It is platform-dependent windowing, graphics, and user-interface widget toolkit preceding Swing. • AWT is part of the Java Foundation Classes (JFC) • the standard API for providing a graphical user interface (GUI) for a Java program.
  • 15. Creating an awt • To create awt example, we have two methods – By extending frame class(Inheritance) – By creating the object of frame class (association)
  • 16. Container • It is a component in AWT • It contain another components like buttons, textfields, labels etc. • The classes that extends Container class are known as container such as Frame, Dialog and Panel.
  • 18. Panel • The Panel is the container that doesn't contain title bar and menu bars. • It can have other components like button, textfield etc.
  • 20. Frame • Frame is the container that contain title bar and can have menu bars. • It can have other components like button, textfield etc.
  • 22. AWT to Swing • AWT: Abstract Windowing Toolkit • import java.awt.* • Swing: • import javax.swing.*
  • 23. Swing
  • 24. Introduction to Swing • It is used to create window-based applications. • It is built on the top of AWT API and entirely written in java. • Swing provides platform-independent and lightweight components.
  • 26. Using a GUI Component 1. Create it • Instantiate object: b = new JButton(“press me”); 2. Configure it • Properties: b.text = “press me”; [avoided in java] • Methods: b.setText(“press me”); 3. Add it • panel.add(b); 4. Listen to it • Events: Listeners JButton
  • 27. Code JFrame f = new JFrame(“title”); JPanel p = new JPanel( ); JButton b = new JButton(“press me”); p.add(b); // add button to panel f.setContentPane(p); // add panel to frame f.show(); press me
  • 28. Application Code import javax.swing.*; class hello { public static void main(String[] args){ JFrame f = new JFrame(“title”); JPanel p = new JPanel(); JButton b = new JButton(“press me”); p.add(b); // add button to panel f.setContentPane(p); // add panel to frame f.show(); } } press me
  • 29. Difference between AWT & Swing Sno AWT SWING 1 Platform dependent Platform Independent 2 Heavyweight components Light weight components 3 Doesn’t support pluggable look and feel Supports pluggable look and feel 4 Less components than swing More powerful components 5 Doesn’t follow MVC Follows MVC
  • 31. Layout Manager Left to right, Top to bottom c n s ew FlowLayout GridLayout BorderLayout none, programmer sets x,y,w,h null One at a time CardLayout GridBagLayout JButton
  • 33. • Changing the state of an object is known as an event. • For example, – click on button, – dragging mouse etc. • The java.awt.event package provides many event classes and Listener interfaces for event handling.
  • 34. Steps to perform Event Handling 1. Implement the Listener interface and overrides its methods 2. Register the component with the Listener