SlideShare a Scribd company logo
GUI Programming  in Java Tim McKenna [email_address]
GUI Programming Concepts conventional programming:  sequence of operations is determined  by the  program what you want to happen, happens when you want it event-driven programming: sequence of operations is determined  by the  user ’s interaction with the application’s  interface anything that can happen, happens at any time
GUI Design Concepts a wealth of information creates a poverty of attention - Herbert Simon  Principles of good GUI Design IBM's  Design concepts Saul Greenberg's  HCI pages Tim's  HCI notes
GUI Programming Concepts in Java Java GUI ("Swing") has  components Windows GUI has  controls Unix GUI has  widgets examples:  labels,   buttons, check boxes, radio buttons, text input boxes, pull down lists Java Swing components:  JLabel,   JButton, JCheckBox, JRadioButton, JTextField, JTextArea, JComboBox
Java GUI history: the AWT AWT(JDK 1.0, 1.1):  Abstract Window Toolkit package: java.awt, java.awt.event heavyweight components using native GUI system elements used for applets until most browsers supported JRE 1.2
Swing in Java Swing(Java 2, JDK 1.2+)  lightweight components that do not rely on the native GUI or OS “ look and feel” of Swing components are identical on different platforms can be customized Swing inherits from AWT AWT still used for events, layouts
Swing Components in Java advanced GUI support. e.g. drag-and-drop package names: javax.swing, javax.swing.event components inherit from JComponent components are added to a top-level container: JFrame, JDialog, or JApplet.
running a Swing application java -Dswing.aatext=true  MySwingClass the option sets the system property "swing.aatext" to "true" to enable anti-aliasing for every JComponent javaw   runs a GUI without the console window e.g. HelloWorldSwing.java
Basic GUI Programming Steps in Java declare a container and components add components to one or more containers using a layout manager register event listener(s) with the components create event listener method(s)
Basic GUI Programming Concepts  in Java Example:  JFrameDemoTM.java, JFrameDemoTM2.java, JFrameDemo.java container :  a screen window/applet window/panel that groups and arranges GUI components GUI component:  an object with visual representation Swing containers:  JFrame, JApplet, JPanel AWT containers:  Frame, Applet, Panel
GUI Programming: The Java Approach event-driven programming a piece of code (i.e.  event handler ) is attached to a GUI component an event handler is called when an  event  (e.g. a mouse click) is activated / fired The Delegation Event Model in Java processing of an event is delegated to an object (the listener) in the program
Event-driven Programming  in Java event source:  a GUI component that  generates / fires  an  event event:  a user interaction (e.g. a click on the button)   event listener:  an object that has implemented  event handlers  to  react  to an  event
Event Handling in Java the delegation event model - event listeners must be    registered  with an event   source in order to receive   notification
Event Handling in Java registration of an event listener - write a class that  implements  an [ event type]Listener interface  - create an instance of that class   (i.e. an event listener) - register the listener with a GUI component: add[event type]Listener ( <an event listener> )
Event Handling in Java a listener interface has a list of standard event handlers (i.e. methods) API documentation - java.awt.event - event classes - listener interfaces - adapter classes
Event Handling in Java different ways of coding the event listeners JFrameDemoTM.java uses named inner classes. JFrameDemoTM2.java uses named inner classes and shows how to consolidate window closing from two different events. JFrameDemo.java does not use inner classes.

More Related Content

Viewers also liked (20)

PPTX
GUI Programming with Java
Jussi Pohjolainen
 
PPT
Mental models
aukee
 
DOCX
Modul oop with java application mauludin
Mauludin Ahmad
 
ZIP
The Game Of Life - Java‘s Siblings and Heirs are populating the Ecosystem
jexp
 
PDF
KC Java Android Talk (March 2011)
osake
 
PPT
First Steps in Android
Rich Helton
 
PPTX
Introduction to Android Development
Prof. Erwin Globio
 
PDF
Google I/O 2013 報告会 Android Studio と Gradle
Keishin Yokomaku
 
PPT
12 gui concepts 1
Jomel Penalba
 
PPT
OOP in Java
wiradikusuma
 
PPTX
GUI Programming in JAVA (Using Netbeans) - A Review
Fernando Torres
 
PDF
Games and Java ME - Have fun and earn some money
Marcelo Quinta
 
KEY
Practical OOP In Java
wiradikusuma
 
PPT
java swing
vannarith
 
PDF
Gui programming (awt)
Ravi_Kant_Sahu
 
PPT
GUI Programming In Java
yht4ever
 
KEY
Android Development: The Basics
Mike Desjardins
 
PPTX
Contingency theory of management
ARUN NAIK
 
PPT
Android ppt
Ansh Singh
 
PDF
Android for Java Developers
Marko Gargenta
 
GUI Programming with Java
Jussi Pohjolainen
 
Mental models
aukee
 
Modul oop with java application mauludin
Mauludin Ahmad
 
The Game Of Life - Java‘s Siblings and Heirs are populating the Ecosystem
jexp
 
KC Java Android Talk (March 2011)
osake
 
First Steps in Android
Rich Helton
 
Introduction to Android Development
Prof. Erwin Globio
 
Google I/O 2013 報告会 Android Studio と Gradle
Keishin Yokomaku
 
12 gui concepts 1
Jomel Penalba
 
OOP in Java
wiradikusuma
 
GUI Programming in JAVA (Using Netbeans) - A Review
Fernando Torres
 
Games and Java ME - Have fun and earn some money
Marcelo Quinta
 
Practical OOP In Java
wiradikusuma
 
java swing
vannarith
 
Gui programming (awt)
Ravi_Kant_Sahu
 
GUI Programming In Java
yht4ever
 
Android Development: The Basics
Mike Desjardins
 
Contingency theory of management
ARUN NAIK
 
Android ppt
Ansh Singh
 
Android for Java Developers
Marko Gargenta
 

Similar to Gu iintro(java) (20)

PPTX
JAVA (UNIT 5)
Dr. SURBHI SAROHA
 
PPT
14a-gui.ppt
DrDGayathriDevi
 
PPTX
Java awt (abstract window toolkit)
Elizabeth alexander
 
PDF
28-GUI application.pptx.pdf
NguynThiThanhTho
 
PDF
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
Jyothishmathi Institute of Technology and Science Karimnagar
 
PPT
engineeringdsgtnotesofunitfivesnists.ppt
sharanyak0721
 
PPT
Basic of Abstract Window Toolkit(AWT) in Java
suraj pandey
 
PPTX
Unit 4_1.pptx JDBC AND GUI FOR CLIENT SERVER
Salini P
 
PPTX
Advance Java Programming(CM5I) Event handling
Payal Dungarwal
 
PPTX
JAVA AWT presentation for awt key events.pptx
ShubhamNain11
 
PPTX
event-handling.pptx
usvirat1805
 
PPTX
object oriented programming examples
Abdii Rashid
 
PDF
Swing
Nataraj Dg
 
PPTX
Java_Unit6pptx__2024_04_13_18_18_07.pptx
lakhatariyajaimin09
 
PPT
Chapter11 graphical components
Arifa Fatima
 
PDF
Gui
Sardar Alam
 
PPTX
JAVA UNIT 5.pptx jejsjdkkdkdkjjndjfjfkfjfnfn
KGowtham16
 
PPS
Java session11
Niit Care
 
PPTX
Java AWT and Java FX
pratikkadam78
 
JAVA (UNIT 5)
Dr. SURBHI SAROHA
 
14a-gui.ppt
DrDGayathriDevi
 
Java awt (abstract window toolkit)
Elizabeth alexander
 
28-GUI application.pptx.pdf
NguynThiThanhTho
 
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
Jyothishmathi Institute of Technology and Science Karimnagar
 
engineeringdsgtnotesofunitfivesnists.ppt
sharanyak0721
 
Basic of Abstract Window Toolkit(AWT) in Java
suraj pandey
 
Unit 4_1.pptx JDBC AND GUI FOR CLIENT SERVER
Salini P
 
Advance Java Programming(CM5I) Event handling
Payal Dungarwal
 
JAVA AWT presentation for awt key events.pptx
ShubhamNain11
 
event-handling.pptx
usvirat1805
 
object oriented programming examples
Abdii Rashid
 
Swing
Nataraj Dg
 
Java_Unit6pptx__2024_04_13_18_18_07.pptx
lakhatariyajaimin09
 
Chapter11 graphical components
Arifa Fatima
 
JAVA UNIT 5.pptx jejsjdkkdkdkjjndjfjfkfjfnfn
KGowtham16
 
Java session11
Niit Care
 
Java AWT and Java FX
pratikkadam78
 
Ad

More from Satish Verma (6)

PPT
Visual Studio .NET2010
Satish Verma
 
PPT
Tutorial csharp
Satish Verma
 
PPT
Introduction to csharp
Satish Verma
 
PPT
C sharp
Satish Verma
 
PPT
(02) c sharp_tutorial
Satish Verma
 
PPT
Visual studio.net
Satish Verma
 
Visual Studio .NET2010
Satish Verma
 
Tutorial csharp
Satish Verma
 
Introduction to csharp
Satish Verma
 
C sharp
Satish Verma
 
(02) c sharp_tutorial
Satish Verma
 
Visual studio.net
Satish Verma
 
Ad

Recently uploaded (20)

PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 

Gu iintro(java)

  • 1. GUI Programming in Java Tim McKenna [email_address]
  • 2. GUI Programming Concepts conventional programming: sequence of operations is determined by the program what you want to happen, happens when you want it event-driven programming: sequence of operations is determined by the user ’s interaction with the application’s interface anything that can happen, happens at any time
  • 3. GUI Design Concepts a wealth of information creates a poverty of attention - Herbert Simon Principles of good GUI Design IBM's Design concepts Saul Greenberg's HCI pages Tim's HCI notes
  • 4. GUI Programming Concepts in Java Java GUI (&quot;Swing&quot;) has components Windows GUI has controls Unix GUI has widgets examples: labels, buttons, check boxes, radio buttons, text input boxes, pull down lists Java Swing components: JLabel, JButton, JCheckBox, JRadioButton, JTextField, JTextArea, JComboBox
  • 5. Java GUI history: the AWT AWT(JDK 1.0, 1.1): Abstract Window Toolkit package: java.awt, java.awt.event heavyweight components using native GUI system elements used for applets until most browsers supported JRE 1.2
  • 6. Swing in Java Swing(Java 2, JDK 1.2+) lightweight components that do not rely on the native GUI or OS “ look and feel” of Swing components are identical on different platforms can be customized Swing inherits from AWT AWT still used for events, layouts
  • 7. Swing Components in Java advanced GUI support. e.g. drag-and-drop package names: javax.swing, javax.swing.event components inherit from JComponent components are added to a top-level container: JFrame, JDialog, or JApplet.
  • 8. running a Swing application java -Dswing.aatext=true MySwingClass the option sets the system property &quot;swing.aatext&quot; to &quot;true&quot; to enable anti-aliasing for every JComponent javaw runs a GUI without the console window e.g. HelloWorldSwing.java
  • 9. Basic GUI Programming Steps in Java declare a container and components add components to one or more containers using a layout manager register event listener(s) with the components create event listener method(s)
  • 10. Basic GUI Programming Concepts in Java Example: JFrameDemoTM.java, JFrameDemoTM2.java, JFrameDemo.java container : a screen window/applet window/panel that groups and arranges GUI components GUI component: an object with visual representation Swing containers: JFrame, JApplet, JPanel AWT containers: Frame, Applet, Panel
  • 11. GUI Programming: The Java Approach event-driven programming a piece of code (i.e. event handler ) is attached to a GUI component an event handler is called when an event (e.g. a mouse click) is activated / fired The Delegation Event Model in Java processing of an event is delegated to an object (the listener) in the program
  • 12. Event-driven Programming in Java event source: a GUI component that generates / fires an event event: a user interaction (e.g. a click on the button) event listener: an object that has implemented event handlers to react to an event
  • 13. Event Handling in Java the delegation event model - event listeners must be registered with an event source in order to receive notification
  • 14. Event Handling in Java registration of an event listener - write a class that implements an [ event type]Listener interface - create an instance of that class (i.e. an event listener) - register the listener with a GUI component: add[event type]Listener ( <an event listener> )
  • 15. Event Handling in Java a listener interface has a list of standard event handlers (i.e. methods) API documentation - java.awt.event - event classes - listener interfaces - adapter classes
  • 16. Event Handling in Java different ways of coding the event listeners JFrameDemoTM.java uses named inner classes. JFrameDemoTM2.java uses named inner classes and shows how to consolidate window closing from two different events. JFrameDemo.java does not use inner classes.