SlideShare a Scribd company logo
GUI Programming   in Java Presented by Thanh Pham [email_address] 06/2007 B070038 – NIIT Quang Trung Because Learning Never Stop!
Contents Basic Concepts 1 AWT and Swing Control Components 2 Layout Manager 3 Event Handling 4 Other References 5
Basic Concepts Basic Concepts Exercises Demos AWT  vs. Swing GUI?
GUI? Graphical User Interface (pronounced "GOO-ee“). Presents a user-friendly mechanism for interacting with an application. Users can learn how to use an app quickly and use it more productively. Ex: Internet Explorer, MS Word, JCreator… GUIs are built from  GUI components  (controls or widgets-window gadget). A GUI component is an object with which the user interacts via the mouse, the keyboard or another form of input, such as voice recognition.
Abstract Window Toolkit (AWT) vs. Swing Similarities: Tools provided by Java for developing interactive GUI applications Provides GUI components that can be used in creating Java applications and applets
Abstract Window Toolkit (AWT) vs. Swing AWT (Abstract Window Toolkit) Some AWT components use native code Platform-dependent Ensure that the look and feel of an application run on different machines be comparable Swing Written entirely using the Java programming language Platform-independent Ensures applications deployed across different platforms have the same appearance Built around a number of APIs that implement various parts of the AWT Can be used with AWT
Demo MessageBox InputBox Create Frame (AWT) Create Frame (Swing) CenterFrame
Exercises Display two input-boxes that accepts two numbers then shows the result. Accepts three numbers, displays the largest, smallest. (Assume that all input values are valid numbers) Create a simple frame
AWT and Swing Control Components AWT and Swing Control Components Exercises Demos Swing AWT
AWT Control Components An AWT control is a component that enables end users to interact with applications created in Java.  All AWT controls in Java are subclasses of the Component class.  The Component class provides the add() method to add AWT components to containers, such as an applet or a window.
AWT Control Components TextField TextArea Button List CheckBox Choice Labels
Demo FrameWithControl
Swing Control Components Swing components contain the Pluggable Look and Feel (PL&F) feature that allows applications to have the same behavior on various platforms.  Identifying the Swing Component Class Hierarchy The JComponent class is the root of the Swing hierarchy, which is an extension of the AWT container class.  The class hierarchy of the Swing components is categorized into:  Top-level Swing Containers: Acts as a container  for placing the intermediate-level and atomic swing components, such as panels, frames, buttons, and check boxes.  Intermediate-level Swing Containers: Placed on the top-level containers and contains atomic components. Atomic Components: Placed on the intermediate-level swing containers. Atomic components are used  to accept input from a user.
Swing Control Components Using the Top-level Swing Containers JApplet The JApplet class is an extension of the AWT applet class.  The Swing components that contain an applet need to extend the JApplet class. The JApplet() constructor  enables you to create a swing applet instance when you create an instance of the JApplet class. JFrame: The JFrame class is an extension of the AWT Frame class.  You cannot add components directly to JFrame.
Swing Control Components Using the Top-level Swing Containers (Cont.) JDialog The JDialog class is an extension of the AWT java.awt.Dialog class. Using the Intermediate Level Swing Containers JPanel JPanel class is an extension of the JComponent class that provides a replacement for the AWT Panel class.  You create a panel and add various components to it.  The panel is further added to the content pane, which represents the display area of a window, a dialog, or a frame.  JPanel supports all layout managers of AWT.  By default, JPanel applies the flow layout manager.
Swing Control Components Using the Intermediate Level Swing Containers (Contd.) JTabbedPane: The JTabbedPane class is used to create a tabbed pane component that enables you to switch between groups of components by clicking a tab with a given label.  Tabs are added to the JTabbedPane object by using the addTab() method.  The JTabbedPane class enables you to add multiple components but it displays only a single component at a time. Using the Atomic Components JButton JTextField  JCheckBox  JComboBox  JLabel  JRadioButton
Demo JFrameWithControl
Exercises
Layout Managers Layout Managers Demo Grid Layout Border  Layout Flow Layout
Layout Managers The layout managers are used to position the components, such as an applet, a panel, or a frame in a container.  The layout managers implement the  java.awt.LayoutManager  interface.  A layout manager is an instance of the  LayoutManager  interface in Java.  You can use the following method to apply the desired layout to the components:  void setLayout(layoutManager obj)   In the preceding syntax, obj is the reference to the desired layout manager.  Java has various predefined classes of layout managers.  All layout managers make use of the  setLayout()  method to set the layout of a container.  If the  setLayout()  method is not used, then the default layout of the container is set.
Layout Managers The different types of layout managers are: FlowLayout Manager  The flow layout is the default layout manager used for the Applet class.  In the flow layout manager, the components are placed in a container window in a sequence one after the other in rows.  Java provides the FlowLayout class to apply flow layout to the various components that you are inserting in an applet.  You can use the following constructors to create an instance of the FlowLayout class:  FlowLayout() FlowLayout(int align) FlowLayout(int align, int hgap,int vgap)
Layout Managers BorderLayout Manager BorderLayout is the default layout of the Frame class.  The BorderLayout layout manager divides the container into north, south, east, west, and centre regions.  You can place five components or controls in each part. Java provides the BorderLayout class to apply the border layout to the components.  The setLayout() method is used for applying border layout to a container.  You specify the directions for the BorderLayout using the BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST, and BorderLayout.CENTER constants.  You can use the following constructors to create an instance of the BorderLayout class: BorderLayout() BorderLayout(int h, int v)
Layout Managers GridLayout Manager  The grid layout is the layout that divides the container into rows and columns.  The intersection of a row and a column of the grid layout is called cell.  The GridLayout class of Java enables you to create a grid layout.  All the components in a grid are of the same size.  You can use the following constructors to create an instance of the GridLayout class:  GridLayout() GridLayout(int r, int c) GridLayout(int r, int c, int h, int v)
Demo FlowLayout BorderLayout GridLayout
To be continued To be continued….
References Java Passion from Sun Microsystems Java Tutorial from Sun Microsystems Core Java 2 Volume I Fundamentals 7 th  Edition Java How to Program 6 th  Edition Java Swing 2 nd  Edition
www.niit-vn.com www.niit-vn.com/4rum Thank You !

More Related Content

What's hot (20)

Java interfaces
Java interfacesJava interfaces
Java interfaces
Raja Sekhar
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Hitesh Kumar
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
Adil Mehmoood
 
Java Collections
Java  Collections Java  Collections
Java Collections
Kongu Engineering College, Perundurai, Erode
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
Praveen M Jigajinni
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
Dhrumil Panchal
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Oop java
Oop javaOop java
Oop java
Minal Maniar
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
Dr Sukhpal Singh Gill
 
Static Members-Java.pptx
Static Members-Java.pptxStatic Members-Java.pptx
Static Members-Java.pptx
ADDAGIRIVENKATARAVIC
 
Swing
SwingSwing
Swing
Jaydeep Viradiya
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
Abhilash Nair
 
Java Swing
Java SwingJava Swing
Java Swing
Arkadeep Dey
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
shanmuga rajan
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classes
Shreyans Pathak
 
Java static keyword
Java static keywordJava static keyword
Java static keyword
Lovely Professional University
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
Jussi Pohjolainen
 
Wrapper classes
Wrapper classes Wrapper classes
Wrapper classes
Kongu Engineering College, Perundurai, Erode
 

Viewers also liked (20)

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
 
Java Swing
Java SwingJava Swing
Java Swing
Shraddha
 
Basic of Java Netbeans
Basic of Java NetbeansBasic of Java Netbeans
Basic of Java Netbeans
Shrey Goswami
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)
Bilal Amjad
 
Swing and Graphical User Interface in Java
Swing and Graphical User Interface in JavaSwing and Graphical User Interface in Java
Swing and Graphical User Interface in Java
babak danyal
 
Gui
GuiGui
Gui
Sardar Alam
 
Netbeans IDE & Platform
Netbeans IDE & PlatformNetbeans IDE & Platform
Netbeans IDE & Platform
Aatul Palandurkar
 
Java swing
Java swingJava swing
Java swing
Nataraj Dg
 
Introduction to java netbeans
Introduction to java netbeansIntroduction to java netbeans
Introduction to java netbeans
Shrey Goswami
 
java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
java swing
java swingjava swing
java swing
vannarith
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART I
OXUS 20
 
JAVA GUI PART III
JAVA GUI PART IIIJAVA GUI PART III
JAVA GUI PART III
OXUS 20
 
Java Swing
Java SwingJava Swing
Java Swing
Komal Gandhi
 
Text field and textarea
Text field and textareaText field and textarea
Text field and textarea
myrajendra
 
GUI programming
GUI programmingGUI programming
GUI programming
Vineeta Garg
 
Java
JavaJava
Java
Anand Grewal
 
Java swings
Java swingsJava swings
Java swings
Alisha Korpal
 
java swing programming
java swing programming java swing programming
java swing programming
Ankit Desai
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-Presented
SlideShare
 
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
 
Java Swing
Java SwingJava Swing
Java Swing
Shraddha
 
Basic of Java Netbeans
Basic of Java NetbeansBasic of Java Netbeans
Basic of Java Netbeans
Shrey Goswami
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)
Bilal Amjad
 
Swing and Graphical User Interface in Java
Swing and Graphical User Interface in JavaSwing and Graphical User Interface in Java
Swing and Graphical User Interface in Java
babak danyal
 
Introduction to java netbeans
Introduction to java netbeansIntroduction to java netbeans
Introduction to java netbeans
Shrey Goswami
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART I
OXUS 20
 
JAVA GUI PART III
JAVA GUI PART IIIJAVA GUI PART III
JAVA GUI PART III
OXUS 20
 
Text field and textarea
Text field and textareaText field and textarea
Text field and textarea
myrajendra
 
java swing programming
java swing programming java swing programming
java swing programming
Ankit Desai
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-Presented
SlideShare
 
Ad

Similar to GUI Programming In Java (20)

Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
Harry Ostaiza
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
renuka gavli
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
backdoor
 
Abstract Window Toolkit_Event Handling_python
Abstract Window Toolkit_Event Handling_pythonAbstract Window Toolkit_Event Handling_python
Abstract Window Toolkit_Event Handling_python
jasminebeulahg
 
swingbasics
swingbasicsswingbasics
swingbasics
Arjun Shanka
 
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdfJEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
MarlouFelixIIICunana
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)
Narayana Swamy
 
MODULE 5.pptx gui programming and applets
MODULE 5.pptx gui programming and appletsMODULE 5.pptx gui programming and applets
MODULE 5.pptx gui programming and applets
LIKITHLIKITH7
 
Java GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdfJava GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdf
PBMaverick
 
java2 swing
java2 swingjava2 swing
java2 swing
guest0282b71
 
UNIT-I.pptx awt advance java abstract windowing toolkit and swing
UNIT-I.pptx awt advance java abstract windowing toolkit and swingUNIT-I.pptx awt advance java abstract windowing toolkit and swing
UNIT-I.pptx awt advance java abstract windowing toolkit and swing
utkarshabhope
 
Advanced Java GUI Programming_ AWT, Swing, and Event Handling_AI PPT Maker.pptx
Advanced Java GUI Programming_ AWT, Swing, and Event Handling_AI PPT Maker.pptxAdvanced Java GUI Programming_ AWT, Swing, and Event Handling_AI PPT Maker.pptx
Advanced Java GUI Programming_ AWT, Swing, and Event Handling_AI PPT Maker.pptx
tarunsocsa
 
Unit 1- awt(Abstract Window Toolkit) .ppt
Unit 1- awt(Abstract Window Toolkit) .pptUnit 1- awt(Abstract Window Toolkit) .ppt
Unit 1- awt(Abstract Window Toolkit) .ppt
Deepgaichor1
 
fdtrdrtttxxxtrtrctctrttrdredrerrrrrrawt.ppt
fdtrdrtttxxxtrtrctctrttrdredrerrrrrrawt.pptfdtrdrtttxxxtrtrctctrttrdredrerrrrrrawt.ppt
fdtrdrtttxxxtrtrctctrttrdredrerrrrrrawt.ppt
havalneha2121
 
awdrdtfffyfyfyfyfyfyfyfyfyfyfyfyyfyt.ppt
awdrdtfffyfyfyfyfyfyfyfyfyfyfyfyyfyt.pptawdrdtfffyfyfyfyfyfyfyfyfyfyfyfyyfyt.ppt
awdrdtfffyfyfyfyfyfyfyfyfyfyfyfyyfyt.ppt
SulbhaBhivsane
 
1.Abstract windowing toolkit.ppt of AJP sub
1.Abstract windowing toolkit.ppt of AJP sub1.Abstract windowing toolkit.ppt of AJP sub
1.Abstract windowing toolkit.ppt of AJP sub
YugandharaNalavade
 
introduction to JAVA awt programmin .ppt
introduction to JAVA awt programmin .pptintroduction to JAVA awt programmin .ppt
introduction to JAVA awt programmin .ppt
bgvthm
 
28 awt
28 awt28 awt
28 awt
Prachi Vijh
 
Swing
SwingSwing
Swing
Fahim Khan
 
Swing
SwingSwing
Swing
Fahim Khan
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
renuka gavli
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
backdoor
 
Abstract Window Toolkit_Event Handling_python
Abstract Window Toolkit_Event Handling_pythonAbstract Window Toolkit_Event Handling_python
Abstract Window Toolkit_Event Handling_python
jasminebeulahg
 
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdfJEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
MarlouFelixIIICunana
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)
Narayana Swamy
 
MODULE 5.pptx gui programming and applets
MODULE 5.pptx gui programming and appletsMODULE 5.pptx gui programming and applets
MODULE 5.pptx gui programming and applets
LIKITHLIKITH7
 
Java GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdfJava GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdf
PBMaverick
 
UNIT-I.pptx awt advance java abstract windowing toolkit and swing
UNIT-I.pptx awt advance java abstract windowing toolkit and swingUNIT-I.pptx awt advance java abstract windowing toolkit and swing
UNIT-I.pptx awt advance java abstract windowing toolkit and swing
utkarshabhope
 
Advanced Java GUI Programming_ AWT, Swing, and Event Handling_AI PPT Maker.pptx
Advanced Java GUI Programming_ AWT, Swing, and Event Handling_AI PPT Maker.pptxAdvanced Java GUI Programming_ AWT, Swing, and Event Handling_AI PPT Maker.pptx
Advanced Java GUI Programming_ AWT, Swing, and Event Handling_AI PPT Maker.pptx
tarunsocsa
 
Unit 1- awt(Abstract Window Toolkit) .ppt
Unit 1- awt(Abstract Window Toolkit) .pptUnit 1- awt(Abstract Window Toolkit) .ppt
Unit 1- awt(Abstract Window Toolkit) .ppt
Deepgaichor1
 
fdtrdrtttxxxtrtrctctrttrdredrerrrrrrawt.ppt
fdtrdrtttxxxtrtrctctrttrdredrerrrrrrawt.pptfdtrdrtttxxxtrtrctctrttrdredrerrrrrrawt.ppt
fdtrdrtttxxxtrtrctctrttrdredrerrrrrrawt.ppt
havalneha2121
 
awdrdtfffyfyfyfyfyfyfyfyfyfyfyfyyfyt.ppt
awdrdtfffyfyfyfyfyfyfyfyfyfyfyfyyfyt.pptawdrdtfffyfyfyfyfyfyfyfyfyfyfyfyyfyt.ppt
awdrdtfffyfyfyfyfyfyfyfyfyfyfyfyyfyt.ppt
SulbhaBhivsane
 
1.Abstract windowing toolkit.ppt of AJP sub
1.Abstract windowing toolkit.ppt of AJP sub1.Abstract windowing toolkit.ppt of AJP sub
1.Abstract windowing toolkit.ppt of AJP sub
YugandharaNalavade
 
introduction to JAVA awt programmin .ppt
introduction to JAVA awt programmin .pptintroduction to JAVA awt programmin .ppt
introduction to JAVA awt programmin .ppt
bgvthm
 
Ad

More from yht4ever (12)

Applications of SOA and Web Services in Grid Computing
Applications of SOA and Web Services in Grid ComputingApplications of SOA and Web Services in Grid Computing
Applications of SOA and Web Services in Grid Computing
yht4ever
 
ERD - Database Design
ERD - Database DesignERD - Database Design
ERD - Database Design
yht4ever
 
Web Page Authoring 1
Web Page Authoring 1Web Page Authoring 1
Web Page Authoring 1
yht4ever
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
yht4ever
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
yht4ever
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
yht4ever
 
XPath - XML Path Language
XPath - XML Path LanguageXPath - XML Path Language
XPath - XML Path Language
yht4ever
 
Rendering XML Document
Rendering XML DocumentRendering XML Document
Rendering XML Document
yht4ever
 
Rendering XML Documents
Rendering XML DocumentsRendering XML Documents
Rendering XML Documents
yht4ever
 
XML Schema
XML SchemaXML Schema
XML Schema
yht4ever
 
Document Type Definition
Document Type DefinitionDocument Type Definition
Document Type Definition
yht4ever
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
yht4ever
 
Applications of SOA and Web Services in Grid Computing
Applications of SOA and Web Services in Grid ComputingApplications of SOA and Web Services in Grid Computing
Applications of SOA and Web Services in Grid Computing
yht4ever
 
ERD - Database Design
ERD - Database DesignERD - Database Design
ERD - Database Design
yht4ever
 
Web Page Authoring 1
Web Page Authoring 1Web Page Authoring 1
Web Page Authoring 1
yht4ever
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
yht4ever
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
yht4ever
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
yht4ever
 
XPath - XML Path Language
XPath - XML Path LanguageXPath - XML Path Language
XPath - XML Path Language
yht4ever
 
Rendering XML Document
Rendering XML DocumentRendering XML Document
Rendering XML Document
yht4ever
 
Rendering XML Documents
Rendering XML DocumentsRendering XML Documents
Rendering XML Documents
yht4ever
 
XML Schema
XML SchemaXML Schema
XML Schema
yht4ever
 
Document Type Definition
Document Type DefinitionDocument Type Definition
Document Type Definition
yht4ever
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
yht4ever
 

Recently uploaded (20)

Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME FlowProviding an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME FlowProviding an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 

GUI Programming In Java

  • 1. GUI Programming in Java Presented by Thanh Pham [email_address] 06/2007 B070038 – NIIT Quang Trung Because Learning Never Stop!
  • 2. Contents Basic Concepts 1 AWT and Swing Control Components 2 Layout Manager 3 Event Handling 4 Other References 5
  • 3. Basic Concepts Basic Concepts Exercises Demos AWT vs. Swing GUI?
  • 4. GUI? Graphical User Interface (pronounced "GOO-ee“). Presents a user-friendly mechanism for interacting with an application. Users can learn how to use an app quickly and use it more productively. Ex: Internet Explorer, MS Word, JCreator… GUIs are built from GUI components (controls or widgets-window gadget). A GUI component is an object with which the user interacts via the mouse, the keyboard or another form of input, such as voice recognition.
  • 5. Abstract Window Toolkit (AWT) vs. Swing Similarities: Tools provided by Java for developing interactive GUI applications Provides GUI components that can be used in creating Java applications and applets
  • 6. Abstract Window Toolkit (AWT) vs. Swing AWT (Abstract Window Toolkit) Some AWT components use native code Platform-dependent Ensure that the look and feel of an application run on different machines be comparable Swing Written entirely using the Java programming language Platform-independent Ensures applications deployed across different platforms have the same appearance Built around a number of APIs that implement various parts of the AWT Can be used with AWT
  • 7. Demo MessageBox InputBox Create Frame (AWT) Create Frame (Swing) CenterFrame
  • 8. Exercises Display two input-boxes that accepts two numbers then shows the result. Accepts three numbers, displays the largest, smallest. (Assume that all input values are valid numbers) Create a simple frame
  • 9. AWT and Swing Control Components AWT and Swing Control Components Exercises Demos Swing AWT
  • 10. AWT Control Components An AWT control is a component that enables end users to interact with applications created in Java. All AWT controls in Java are subclasses of the Component class. The Component class provides the add() method to add AWT components to containers, such as an applet or a window.
  • 11. AWT Control Components TextField TextArea Button List CheckBox Choice Labels
  • 13. Swing Control Components Swing components contain the Pluggable Look and Feel (PL&F) feature that allows applications to have the same behavior on various platforms. Identifying the Swing Component Class Hierarchy The JComponent class is the root of the Swing hierarchy, which is an extension of the AWT container class. The class hierarchy of the Swing components is categorized into: Top-level Swing Containers: Acts as a container for placing the intermediate-level and atomic swing components, such as panels, frames, buttons, and check boxes. Intermediate-level Swing Containers: Placed on the top-level containers and contains atomic components. Atomic Components: Placed on the intermediate-level swing containers. Atomic components are used to accept input from a user.
  • 14. Swing Control Components Using the Top-level Swing Containers JApplet The JApplet class is an extension of the AWT applet class. The Swing components that contain an applet need to extend the JApplet class. The JApplet() constructor enables you to create a swing applet instance when you create an instance of the JApplet class. JFrame: The JFrame class is an extension of the AWT Frame class. You cannot add components directly to JFrame.
  • 15. Swing Control Components Using the Top-level Swing Containers (Cont.) JDialog The JDialog class is an extension of the AWT java.awt.Dialog class. Using the Intermediate Level Swing Containers JPanel JPanel class is an extension of the JComponent class that provides a replacement for the AWT Panel class. You create a panel and add various components to it. The panel is further added to the content pane, which represents the display area of a window, a dialog, or a frame. JPanel supports all layout managers of AWT. By default, JPanel applies the flow layout manager.
  • 16. Swing Control Components Using the Intermediate Level Swing Containers (Contd.) JTabbedPane: The JTabbedPane class is used to create a tabbed pane component that enables you to switch between groups of components by clicking a tab with a given label. Tabs are added to the JTabbedPane object by using the addTab() method. The JTabbedPane class enables you to add multiple components but it displays only a single component at a time. Using the Atomic Components JButton JTextField JCheckBox JComboBox JLabel JRadioButton
  • 19. Layout Managers Layout Managers Demo Grid Layout Border Layout Flow Layout
  • 20. Layout Managers The layout managers are used to position the components, such as an applet, a panel, or a frame in a container. The layout managers implement the java.awt.LayoutManager interface. A layout manager is an instance of the LayoutManager interface in Java. You can use the following method to apply the desired layout to the components: void setLayout(layoutManager obj) In the preceding syntax, obj is the reference to the desired layout manager. Java has various predefined classes of layout managers. All layout managers make use of the setLayout() method to set the layout of a container. If the setLayout() method is not used, then the default layout of the container is set.
  • 21. Layout Managers The different types of layout managers are: FlowLayout Manager The flow layout is the default layout manager used for the Applet class. In the flow layout manager, the components are placed in a container window in a sequence one after the other in rows. Java provides the FlowLayout class to apply flow layout to the various components that you are inserting in an applet. You can use the following constructors to create an instance of the FlowLayout class: FlowLayout() FlowLayout(int align) FlowLayout(int align, int hgap,int vgap)
  • 22. Layout Managers BorderLayout Manager BorderLayout is the default layout of the Frame class. The BorderLayout layout manager divides the container into north, south, east, west, and centre regions. You can place five components or controls in each part. Java provides the BorderLayout class to apply the border layout to the components. The setLayout() method is used for applying border layout to a container. You specify the directions for the BorderLayout using the BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST, and BorderLayout.CENTER constants. You can use the following constructors to create an instance of the BorderLayout class: BorderLayout() BorderLayout(int h, int v)
  • 23. Layout Managers GridLayout Manager The grid layout is the layout that divides the container into rows and columns. The intersection of a row and a column of the grid layout is called cell. The GridLayout class of Java enables you to create a grid layout. All the components in a grid are of the same size. You can use the following constructors to create an instance of the GridLayout class: GridLayout() GridLayout(int r, int c) GridLayout(int r, int c, int h, int v)
  • 25. To be continued To be continued….
  • 26. References Java Passion from Sun Microsystems Java Tutorial from Sun Microsystems Core Java 2 Volume I Fundamentals 7 th Edition Java How to Program 6 th Edition Java Swing 2 nd Edition