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.
Ad

More Related Content

Viewers also liked (20)

GUI Programming with Java
GUI Programming with JavaGUI Programming with Java
GUI Programming with Java
Jussi Pohjolainen
 
Mental models
Mental modelsMental models
Mental models
aukee
 
Modul oop with java application mauludin
Modul oop with java application   mauludinModul oop with java application   mauludin
Modul oop with java application mauludin
Mauludin Ahmad
 
The Game Of Life - Java‘s Siblings and Heirs are populating the Ecosystem
The Game Of Life - Java‘s Siblings and Heirs are populating  the EcosystemThe Game Of Life - Java‘s Siblings and Heirs are populating  the Ecosystem
The Game Of Life - Java‘s Siblings and Heirs are populating the Ecosystem
jexp
 
KC Java Android Talk (March 2011)
KC Java Android Talk (March 2011)KC Java Android Talk (March 2011)
KC Java Android Talk (March 2011)
osake
 
First Steps in Android
First Steps in AndroidFirst Steps in Android
First Steps in Android
Rich Helton
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
Prof. Erwin Globio
 
Google I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と GradleGoogle I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と Gradle
Keishin Yokomaku
 
12 gui concepts 1
12 gui concepts 112 gui concepts 1
12 gui concepts 1
Jomel Penalba
 
OOP in Java
OOP in JavaOOP in Java
OOP in Java
wiradikusuma
 
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
Fernando Torres
 
Games and Java ME - Have fun and earn some money
Games and Java ME - Have fun and earn some moneyGames and Java ME - Have fun and earn some money
Games and Java ME - Have fun and earn some money
Marcelo Quinta
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Java
wiradikusuma
 
java swing
java swingjava swing
java swing
vannarith
 
Gui programming (awt)
Gui programming (awt)Gui programming (awt)
Gui programming (awt)
Ravi_Kant_Sahu
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
yht4ever
 
Android Development: The Basics
Android Development: The BasicsAndroid Development: The Basics
Android Development: The Basics
Mike Desjardins
 
Contingency theory of management
Contingency theory of managementContingency theory of management
Contingency theory of management
ARUN NAIK
 
Android ppt
Android pptAndroid ppt
Android ppt
Ansh Singh
 
Android for Java Developers
Android for Java DevelopersAndroid for Java Developers
Android for Java Developers
Marko Gargenta
 
Mental models
Mental modelsMental models
Mental models
aukee
 
Modul oop with java application mauludin
Modul oop with java application   mauludinModul oop with java application   mauludin
Modul oop with java application mauludin
Mauludin Ahmad
 
The Game Of Life - Java‘s Siblings and Heirs are populating the Ecosystem
The Game Of Life - Java‘s Siblings and Heirs are populating  the EcosystemThe Game Of Life - Java‘s Siblings and Heirs are populating  the Ecosystem
The Game Of Life - Java‘s Siblings and Heirs are populating the Ecosystem
jexp
 
KC Java Android Talk (March 2011)
KC Java Android Talk (March 2011)KC Java Android Talk (March 2011)
KC Java Android Talk (March 2011)
osake
 
First Steps in Android
First Steps in AndroidFirst Steps in Android
First Steps in Android
Rich Helton
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
Prof. Erwin Globio
 
Google I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と GradleGoogle I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と Gradle
Keishin Yokomaku
 
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
Fernando Torres
 
Games and Java ME - Have fun and earn some money
Games and Java ME - Have fun and earn some moneyGames and Java ME - Have fun and earn some money
Games and Java ME - Have fun and earn some money
Marcelo Quinta
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Java
wiradikusuma
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
yht4ever
 
Android Development: The Basics
Android Development: The BasicsAndroid Development: The Basics
Android Development: The Basics
Mike Desjardins
 
Contingency theory of management
Contingency theory of managementContingency theory of management
Contingency theory of management
ARUN NAIK
 
Android for Java Developers
Android for Java DevelopersAndroid for Java Developers
Android for Java Developers
Marko Gargenta
 

Similar to Gu iintro(java) (20)

JAVA (UNIT 5)
JAVA (UNIT 5)JAVA (UNIT 5)
JAVA (UNIT 5)
Dr. SURBHI SAROHA
 
Slot04 creating gui
Slot04 creating guiSlot04 creating gui
Slot04 creating gui
Viên Mai
 
Java_Unit6pptx__2024_04_13_18_18_07.pptx
Java_Unit6pptx__2024_04_13_18_18_07.pptxJava_Unit6pptx__2024_04_13_18_18_07.pptx
Java_Unit6pptx__2024_04_13_18_18_07.pptx
lakhatariyajaimin09
 
Applications use in Java GUIThe Java GUI consists of a separate, .pdf
Applications use in Java GUIThe Java GUI consists of a separate, .pdfApplications use in Java GUIThe Java GUI consists of a separate, .pdf
Applications use in Java GUIThe Java GUI consists of a separate, .pdf
akshay1213
 
GUI JAVA PROG ~hmftj
GUI  JAVA PROG ~hmftjGUI  JAVA PROG ~hmftj
GUI JAVA PROG ~hmftj
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
sharanyak0721
 
ITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptxITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptx
udithaisur
 
Java session11
Java session11Java session11
Java session11
Niit Care
 
The java rogramming swing _tutorial for beinners(java programming language)
The java rogramming swing _tutorial for beinners(java programming language)The java rogramming swing _tutorial for beinners(java programming language)
The java rogramming swing _tutorial for beinners(java programming language)
Daroko blog(www.professionalbloggertricks.com)
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorial
sumitjoshi01
 
GUI design using JAVAFX.ppt
GUI design using JAVAFX.pptGUI design using JAVAFX.ppt
GUI design using JAVAFX.ppt
TabassumMaktum
 
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 and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
Shehrevar Davierwala
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
Yiguang Hu
 
Java gui event
Java gui eventJava gui event
Java gui event
SoftNutx
 
Windows Programming with Swing
Windows Programming with SwingWindows Programming with Swing
Windows Programming with Swing
backdoor
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
amitksaha
 
Ch12. graphical user interfaces
Ch12. graphical user interfacesCh12. graphical user interfaces
Ch12. graphical user interfaces
Arslan Karamat
 
Lecture8 oopj
Lecture8 oopjLecture8 oopj
Lecture8 oopj
Dhairya Joshi
 
Slot04 creating gui
Slot04 creating guiSlot04 creating gui
Slot04 creating gui
Viên Mai
 
Java_Unit6pptx__2024_04_13_18_18_07.pptx
Java_Unit6pptx__2024_04_13_18_18_07.pptxJava_Unit6pptx__2024_04_13_18_18_07.pptx
Java_Unit6pptx__2024_04_13_18_18_07.pptx
lakhatariyajaimin09
 
Applications use in Java GUIThe Java GUI consists of a separate, .pdf
Applications use in Java GUIThe Java GUI consists of a separate, .pdfApplications use in Java GUIThe Java GUI consists of a separate, .pdf
Applications use in Java GUIThe Java GUI consists of a separate, .pdf
akshay1213
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
sharanyak0721
 
ITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptxITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptx
udithaisur
 
Java session11
Java session11Java session11
Java session11
Niit Care
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorial
sumitjoshi01
 
GUI design using JAVAFX.ppt
GUI design using JAVAFX.pptGUI design using JAVAFX.ppt
GUI design using JAVAFX.ppt
TabassumMaktum
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
Yiguang Hu
 
Java gui event
Java gui eventJava gui event
Java gui event
SoftNutx
 
Windows Programming with Swing
Windows Programming with SwingWindows Programming with Swing
Windows Programming with Swing
backdoor
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
amitksaha
 
Ch12. graphical user interfaces
Ch12. graphical user interfacesCh12. graphical user interfaces
Ch12. graphical user interfaces
Arslan Karamat
 
Ad

More from Satish Verma (6)

Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
Satish Verma
 
Tutorial csharp
Tutorial csharpTutorial csharp
Tutorial csharp
Satish Verma
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
Satish Verma
 
C sharp
C sharpC sharp
C sharp
Satish Verma
 
(02) c sharp_tutorial
(02) c sharp_tutorial(02) c sharp_tutorial
(02) c sharp_tutorial
Satish Verma
 
Visual studio.net
Visual studio.netVisual studio.net
Visual studio.net
Satish Verma
 
Ad

Recently uploaded (20)

Agentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community MeetupAgentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community Meetup
Manoj Batra (1600 + Connections)
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
CSUC - Consorci de Serveis Universitaris de Catalunya
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
Top-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptxTop-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptx
BR Softech
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
Top-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptxTop-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptx
BR Softech
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 

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.
  翻译: