SlideShare a Scribd company logo
1 of 28
GUI(Graphical User Interface)
Rishi Ram Khanal
BIM (TU)
Introduction to GUI
• Graphical user interface is a type of user interface
that allows users to interact with the screen using
graphical components(Visual Indicators) rather
than text commands.
• There are two sets of Java APIs(Application
Programming Interface) for graphics
Programming:
1.AWT(Abstract Windowing Toolkit)
2.Swing
AWT
• It consist of 12 packages
• Only 2 packages-java.awt and java.awt.event
are commonly used
• The java.awt package contains the core AWT
graphics classes
• GUI component classes(such as Button, Textfield ,label)
• GUI container classes(frame ,panel,Dialog)
• Layout mananger(flowlayout,Borderlayout,Gridlayout)
• Custom graphic classes(Graphic,Color,Font)
AWT Events
• The java .awt.event package supports event
handling
• Event classes (ActionEvent,
MouseEvent,KeyEvent and WindowEvent)
• Event Listener Interfaces(Such as
ActionListener,Mouselistener,
WindowsListener)
Container
• A frame is the top –level container of an AWT
GUI program
• A panel is a rectangular area(or portion) used
to group related GUI components
• In a GUI program , a component must be kept
in a container
• Every container has a method called
add(Component c)
APPLET
• An applet is a java program that runs in a Web browser
• Applet is a container class like Frame
• An applet is a java class that extends the
java.applet.Applet class
• Applets are designed to be embedded within an HTML
page
• When a user views an Html page that contains an
applet ,the code for the applet is downloaded to the
user’s machine
• A JVM is required to view an applet
PRATICAL
• How to make an applet Program?
• How a programmer can compile and run an
applet code?
• How applet can be embedded in the HTML
code?
LIFE CYCLE OF APPLET
• JVM on the user’s machine creates an instance of
the applet class and invokes various methods
during the applet’s life time
• Four method in the Applet class give you the
framework on which you can build any applet
Application
• Init()
• Start()
• Stop()
• Destroy()
• Paint()(important function but not a part of Lifecycle)
How to set Components in Applet
• Component
• Button
• Textfield
• Label
• CheckBox
• List
• We need to design GUI so that user can
interact with the applet
• We have to place component on the applet
container , to meet this requirement
For pratical
• Basic Skeleton of an applet
• Creating Component reference variables
• Initialize Components
• Adding Components to the applet
• Setting layout
Event Handling in an Applet In java
• Event
Changing the state of an object is knows
as Event. For example click on button,
dragging mouse, minimizing window etc
The java.awt.event package provides many
event classes and Listener interfaces for event
handling
Event handling is to make java code ready to
respond any particular event
Feeling of a button
Hey , I am button
class object. user can
click me, but I don’t
know what to run
when he does that
Feeling of the programmer(you)
I am the programmer , I have to write code that
should be executed on click of a button
Public void someFunction()
{
write some code
}
Struggling phase:
But do my function get to know that
button has just clicked?
Two Ends Of Story
Hey programmer , I have method to
register to register your code with me
Ok that means
button.addActionListener();
Communication can solve the issue
Yes , but you have to pass an object to
function
Button.addActionListener(here?);
But object of which class?
See prototype defined in Button class
Public void addActionListener(ActionListener,
actionlistener)
But ActionListener ia an interface, which I have to
pass an object of class which implements
ActionLIstener.
Button.addActionListener(object);
Ok, then I have to make a class which implements
ActionListener
Class Myhandler implements ActionListener
{
Public void someFunction (ActionEvent e)
{
write some code
}
}
Button.addActionListener(new MyHandler());
This is the way I can register my
handler with my Button object
Now I have an object
of Myhandler
referenced by
actionListener(a
reference variable of
ActionListener)
Parameter Passing in an Applet
<param> tag
• Parameter are passed to applets in Name=Value
pairs in <param> tags betweeen the opening and
closing applet tags
• Inside the applet , you read the values passed
through the param tags with the getParameter()
method of the java.applet.Applet class
Import java.applet.Applet;
Import java.awt.*;
/*<applet code=“Myapplet” width=“300” height=“500”
<param name=“saroj” value=“paras”></param></applet>
Public class Myapplet extends Applet
{
String message=“hello”;
Public void paint(Graphics s)
{
String s1=this.getParameter(“saroj”);
if(s1==null)
s1=message;
s.drawString(s1,150,150);
}
}
Introduction to AWT
• Java Awt(Abstract Windowing Toolkit) is an
API to develop GUI or window-based
application in java.
• AWT classes
• GUI component classes(such as Button, Textfield ,label)
• GUI container classes(frame ,panel,DialogBoxes)
• Layout mananger(flowlayout,Borderlayout,Gridlayout)
• Custom graphic classes(Graphic,Color,Font)
• Event Handling
classes(AWTEvent,AwteEventMultiCaster)
Hierarchy of java AWT classes
Frame
• The Frame is the container that contain title bar
and can have menu bars. It can have other
components like button, textfield etc.
• The window is the container that have no borders
and menu bars. You must use frame, dialog or
another window for creating a window.
• The Panel is the container that doesn't contain
title bar and menu bars. It can have other
components like button, textfield etc.
Working with Frame Window
• Setting the window’s Dimensions
Void setSize(init newWidth, init newHeight)
void setSize(Dimension newSize)
getSize() method is used to obtain current size
of a window.
• Hiding and showing a window
void setVisible(boolean visibleFlag)
Setting a window’s Title
void setTitle(String newTitle)
Example of AWT frame
Import java.awt.*;
Class MyFrame extends Frame
{
MyFrame()
{
setTitle(“Myfirst Frame”);
setSize(200,200);
Button b=new Button(“click Me”);
setLayout(null);
b.setBounds(50,50,50,50);
add(b);
setVisible(true);
}
}
Practical

More Related Content

What's hot

What's hot (20)

GUI Programming with Java
GUI Programming with JavaGUI Programming with Java
GUI Programming with Java
 
Awt
AwtAwt
Awt
 
Event Handling in Java
Event Handling in JavaEvent Handling in Java
Event Handling in Java
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
Advance Java Programming(CM5I) Event handling
Advance Java Programming(CM5I) Event handlingAdvance Java Programming(CM5I) Event handling
Advance Java Programming(CM5I) Event handling
 
Event handling
Event handlingEvent handling
Event handling
 
Event Handling in JAVA
Event Handling in JAVAEvent Handling in JAVA
Event Handling in JAVA
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
 
Event handling
Event handlingEvent handling
Event handling
 
GUI Programming in JAVA (Using Netbeans) - A Review
GUI Programming in JAVA (Using Netbeans) -  A ReviewGUI Programming in JAVA (Using Netbeans) -  A Review
GUI Programming in JAVA (Using Netbeans) - A Review
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
Swing
SwingSwing
Swing
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Java awt tutorial javatpoint
Java awt tutorial   javatpointJava awt tutorial   javatpoint
Java awt tutorial javatpoint
 
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
 
java swing
java swingjava swing
java swing
 
Event handling
Event handlingEvent handling
Event handling
 
tL19 awt
tL19 awttL19 awt
tL19 awt
 
Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWT
 
GUI programming
GUI programmingGUI programming
GUI programming
 

Similar to GUI (graphical user interface) (20)

object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examples
 
Java Applets
Java AppletsJava Applets
Java Applets
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
JAVA (UNIT 5)
JAVA (UNIT 5)JAVA (UNIT 5)
JAVA (UNIT 5)
 
Java Applet
Java AppletJava Applet
Java Applet
 
Applet in java
Applet in javaApplet in java
Applet in java
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
 
GUI.pdf
GUI.pdfGUI.pdf
GUI.pdf
 
17625-1.pptx
17625-1.pptx17625-1.pptx
17625-1.pptx
 
AWT.pptx
AWT.pptxAWT.pptx
AWT.pptx
 
applet.pptx
applet.pptxapplet.pptx
applet.pptx
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
 
Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
 
Awt event
Awt eventAwt event
Awt event
 
Java applet
Java appletJava applet
Java applet
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
java- Abstract Window toolkit
java- Abstract Window toolkitjava- Abstract Window toolkit
java- Abstract Window toolkit
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
 

More from rishi ram khanal

Measurement of gdp under product method
Measurement of gdp under product methodMeasurement of gdp under product method
Measurement of gdp under product methodrishi ram khanal
 
Major social problem in nepal child labour socilology
Major social problem in nepal child labour socilologyMajor social problem in nepal child labour socilology
Major social problem in nepal child labour socilologyrishi ram khanal
 
Introduction to artificial intelligence
Introduction to artificial intelligenceIntroduction to artificial intelligence
Introduction to artificial intelligencerishi ram khanal
 
Interview method in research
Interview method in researchInterview method in research
Interview method in researchrishi ram khanal
 
Presentation on kurtosis statistics
Presentation on kurtosis statisticsPresentation on kurtosis statistics
Presentation on kurtosis statisticsrishi ram khanal
 
Importance of double entry accounting system for public limited company (basi...
Importance of double entry accounting system for public limited company (basi...Importance of double entry accounting system for public limited company (basi...
Importance of double entry accounting system for public limited company (basi...rishi ram khanal
 
Implementation issues software engineering
Implementation issues software engineeringImplementation issues software engineering
Implementation issues software engineeringrishi ram khanal
 
Effect of migration in developing country
Effect of migration in developing countryEffect of migration in developing country
Effect of migration in developing countryrishi ram khanal
 
Goals of firm business finance
Goals of firm business financeGoals of firm business finance
Goals of firm business financerishi ram khanal
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)rishi ram khanal
 
GDP and trends economics .rishi
GDP and trends economics .rishiGDP and trends economics .rishi
GDP and trends economics .rishirishi ram khanal
 
Final internship-report on the networking department of the internet service ...
Final internship-report on the networking department of the internet service ...Final internship-report on the networking department of the internet service ...
Final internship-report on the networking department of the internet service ...rishi ram khanal
 
Field study of crystal finance share broker
Field study of crystal finance share brokerField study of crystal finance share broker
Field study of crystal finance share brokerrishi ram khanal
 
Database management system
Database management systemDatabase management system
Database management systemrishi ram khanal
 
Credential reuse cyber security
Credential reuse cyber securityCredential reuse cyber security
Credential reuse cyber securityrishi ram khanal
 
Cisco packet tracer router
Cisco packet tracer  routerCisco packet tracer  router
Cisco packet tracer routerrishi ram khanal
 

More from rishi ram khanal (20)

Measurement of gdp under product method
Measurement of gdp under product methodMeasurement of gdp under product method
Measurement of gdp under product method
 
Major social problem in nepal child labour socilology
Major social problem in nepal child labour socilologyMajor social problem in nepal child labour socilology
Major social problem in nepal child labour socilology
 
Light source ooad
Light source ooadLight source ooad
Light source ooad
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Introduction to artificial intelligence
Introduction to artificial intelligenceIntroduction to artificial intelligence
Introduction to artificial intelligence
 
Interview method in research
Interview method in researchInterview method in research
Interview method in research
 
Presentation on kurtosis statistics
Presentation on kurtosis statisticsPresentation on kurtosis statistics
Presentation on kurtosis statistics
 
Importance of double entry accounting system for public limited company (basi...
Importance of double entry accounting system for public limited company (basi...Importance of double entry accounting system for public limited company (basi...
Importance of double entry accounting system for public limited company (basi...
 
Implementation issues software engineering
Implementation issues software engineeringImplementation issues software engineering
Implementation issues software engineering
 
Effect of migration in developing country
Effect of migration in developing countryEffect of migration in developing country
Effect of migration in developing country
 
Goals of firm business finance
Goals of firm business financeGoals of firm business finance
Goals of firm business finance
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)
 
GDP and trends economics .rishi
GDP and trends economics .rishiGDP and trends economics .rishi
GDP and trends economics .rishi
 
Final internship-report on the networking department of the internet service ...
Final internship-report on the networking department of the internet service ...Final internship-report on the networking department of the internet service ...
Final internship-report on the networking department of the internet service ...
 
Field study of crystal finance share broker
Field study of crystal finance share brokerField study of crystal finance share broker
Field study of crystal finance share broker
 
Dijkstra algorithm
Dijkstra algorithmDijkstra algorithm
Dijkstra algorithm
 
Computer virus and worms
Computer virus and wormsComputer virus and worms
Computer virus and worms
 
Database management system
Database management systemDatabase management system
Database management system
 
Credential reuse cyber security
Credential reuse cyber securityCredential reuse cyber security
Credential reuse cyber security
 
Cisco packet tracer router
Cisco packet tracer  routerCisco packet tracer  router
Cisco packet tracer router
 

Recently uploaded

Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 

Recently uploaded (20)

Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 

GUI (graphical user interface)

  • 2. Introduction to GUI • Graphical user interface is a type of user interface that allows users to interact with the screen using graphical components(Visual Indicators) rather than text commands. • There are two sets of Java APIs(Application Programming Interface) for graphics Programming: 1.AWT(Abstract Windowing Toolkit) 2.Swing
  • 3. AWT • It consist of 12 packages • Only 2 packages-java.awt and java.awt.event are commonly used • The java.awt package contains the core AWT graphics classes • GUI component classes(such as Button, Textfield ,label) • GUI container classes(frame ,panel,Dialog) • Layout mananger(flowlayout,Borderlayout,Gridlayout) • Custom graphic classes(Graphic,Color,Font)
  • 4. AWT Events • The java .awt.event package supports event handling • Event classes (ActionEvent, MouseEvent,KeyEvent and WindowEvent) • Event Listener Interfaces(Such as ActionListener,Mouselistener, WindowsListener)
  • 5. Container • A frame is the top –level container of an AWT GUI program • A panel is a rectangular area(or portion) used to group related GUI components • In a GUI program , a component must be kept in a container • Every container has a method called add(Component c)
  • 6.
  • 7. APPLET • An applet is a java program that runs in a Web browser • Applet is a container class like Frame • An applet is a java class that extends the java.applet.Applet class • Applets are designed to be embedded within an HTML page • When a user views an Html page that contains an applet ,the code for the applet is downloaded to the user’s machine • A JVM is required to view an applet
  • 8. PRATICAL • How to make an applet Program? • How a programmer can compile and run an applet code? • How applet can be embedded in the HTML code?
  • 9. LIFE CYCLE OF APPLET • JVM on the user’s machine creates an instance of the applet class and invokes various methods during the applet’s life time • Four method in the Applet class give you the framework on which you can build any applet Application • Init() • Start() • Stop() • Destroy() • Paint()(important function but not a part of Lifecycle)
  • 10. How to set Components in Applet • Component • Button • Textfield • Label • CheckBox • List • We need to design GUI so that user can interact with the applet • We have to place component on the applet container , to meet this requirement
  • 11. For pratical • Basic Skeleton of an applet • Creating Component reference variables • Initialize Components • Adding Components to the applet • Setting layout
  • 12. Event Handling in an Applet In java • Event Changing the state of an object is knows as Event. For example click on button, dragging mouse, minimizing window etc The java.awt.event package provides many event classes and Listener interfaces for event handling Event handling is to make java code ready to respond any particular event
  • 13. Feeling of a button Hey , I am button class object. user can click me, but I don’t know what to run when he does that
  • 14. Feeling of the programmer(you) I am the programmer , I have to write code that should be executed on click of a button Public void someFunction() { write some code } Struggling phase: But do my function get to know that button has just clicked?
  • 15. Two Ends Of Story Hey programmer , I have method to register to register your code with me Ok that means button.addActionListener();
  • 16. Communication can solve the issue Yes , but you have to pass an object to function Button.addActionListener(here?); But object of which class?
  • 17. See prototype defined in Button class Public void addActionListener(ActionListener, actionlistener) But ActionListener ia an interface, which I have to pass an object of class which implements ActionLIstener. Button.addActionListener(object);
  • 18. Ok, then I have to make a class which implements ActionListener Class Myhandler implements ActionListener { Public void someFunction (ActionEvent e) { write some code } }
  • 19. Button.addActionListener(new MyHandler()); This is the way I can register my handler with my Button object
  • 20. Now I have an object of Myhandler referenced by actionListener(a reference variable of ActionListener)
  • 21. Parameter Passing in an Applet <param> tag • Parameter are passed to applets in Name=Value pairs in <param> tags betweeen the opening and closing applet tags • Inside the applet , you read the values passed through the param tags with the getParameter() method of the java.applet.Applet class
  • 22. Import java.applet.Applet; Import java.awt.*; /*<applet code=“Myapplet” width=“300” height=“500” <param name=“saroj” value=“paras”></param></applet> Public class Myapplet extends Applet { String message=“hello”; Public void paint(Graphics s) { String s1=this.getParameter(“saroj”); if(s1==null) s1=message; s.drawString(s1,150,150); } }
  • 23. Introduction to AWT • Java Awt(Abstract Windowing Toolkit) is an API to develop GUI or window-based application in java. • AWT classes • GUI component classes(such as Button, Textfield ,label) • GUI container classes(frame ,panel,DialogBoxes) • Layout mananger(flowlayout,Borderlayout,Gridlayout) • Custom graphic classes(Graphic,Color,Font) • Event Handling classes(AWTEvent,AwteEventMultiCaster)
  • 24. Hierarchy of java AWT classes
  • 25. Frame • The Frame is the container that contain title bar and can have menu bars. It can have other components like button, textfield etc. • The window is the container that have no borders and menu bars. You must use frame, dialog or another window for creating a window. • The Panel is the container that doesn't contain title bar and menu bars. It can have other components like button, textfield etc.
  • 26. Working with Frame Window • Setting the window’s Dimensions Void setSize(init newWidth, init newHeight) void setSize(Dimension newSize) getSize() method is used to obtain current size of a window. • Hiding and showing a window void setVisible(boolean visibleFlag) Setting a window’s Title void setTitle(String newTitle)
  • 27. Example of AWT frame Import java.awt.*; Class MyFrame extends Frame { MyFrame() { setTitle(“Myfirst Frame”); setSize(200,200); Button b=new Button(“click Me”); setLayout(null); b.setBounds(50,50,50,50); add(b); setVisible(true); } }