SlideShare une entreprise Scribd logo
1  sur  17
Télécharger pour lire hors ligne
» GUI
˃
˃
˃
˃

https://www.facebook.com/Oxus20

oxus20@gmail.com

Introduction
AWT Package
Swing Package
Frame vs. JFrame

JAVA
GUI
PART I
Milad Kawesh
Agenda
» Introduction
˃ GUI (Graphical User Interface)
˃ Simple Example

» AWT and Swing Package
˃ AWT
˃ Swing
˃ JFrame vs. Frame
˃ Simple Example
2

https://www.facebook.com/Oxus20
Introduction
» A Graphical User Interface (GUI) presents a

user-friendly mechanism for interacting with
an application.
˃ Gives an application a distinctive "look" and "feel".
˃ Consistent, intuitive user-interface components give users a sense of
familiarity .
˃ Learn new applications more quickly and use them more
productively.
3

https://www.facebook.com/Oxus20
Introduction (cont..)
» Built from GUI components.
˃ Sometimes called controls or widgets

» User interacts via the mouse, the keyboard or another
form of input, such as voice recognition.
» IDEs
˃ Provide GUI design tools to specify a component's exact size and location in a visual
manner by using the mouse.
˃ Generates the GUI code for you.

˃ Greatly simplifies creating GUIs, but each IDE has different capabilities and generates
different code.
4

https://www.facebook.com/Oxus20
Simple GUI-Based Input / Output with
JOptionPane
» Most applications use windows or dialog boxes (also called

dialogs) to interact with the user.
» JOptionPane (javax.swing package) provides prebuilt dialog
boxes for input and output
˃ Displayed via static JOptionPane methods.

» Next Example uses two input dialogs to get input from the

user and a message dialog to display the sum of the given
input.

5

https://www.facebook.com/Oxus20
Simple GUI example
import javax.swing.JOptionPane;
public class Multiplier {
public static void main(String[] args) {
String firstNumber = JOptionPane.showInputDialog("Enter first number");
String secondNumber = JOptionPane.showInputDialog("Enter Second number");

int number1 = Integer.parseInt(firstNumber);
int number2 = Integer.parseInt(secondNumber);
int result = number1 * number2;
JOptionPane.showMessageDialog(null, "The Multiply of " + number1
+ " and " +number2 + " is " + result, "Result", JOptionPane.PLAIN_MESSAGE);
}
}
6

https://www.facebook.com/Oxus20
Preview

7

https://www.facebook.com/Oxus20
More on GUI
"AWT and Swing"
8

8
https://www.facebook.com/Oxus20
AWT Vs. Swing
» When Java was first released in 1995, it contained a GUI API
referred to as the Abstract Windowing Toolkit (AWT).
» The classes and interfaces of the AWT are in the java.awt
package.

» Aware of the need for a more robust API for creating GUI
applications, Sun Microsystems teamed together with

Netscape (and other industry partners) then created Swing
package.
https://www.facebook.com/Oxus20

9
AWT Vs. Swing (cont.)
» Swing is actually a part of the Java Foundation Classes

(JFC).
» The classes and interfaces of Swing are found in the
javax.swing package.
» AWT components are referred to as heavyweight
components because their implementation relies
heavily on the underlying Operating System.
10

https://www.facebook.com/Oxus20
AWT Vs. Swing (cont.)
» The look and feel of AWT components depend on the platform
the program is running on.
˃

For example, an AWT button will look like a Windows button when the program is run on a Windows
platform.

» Swing components are referred to as lightweight components
because their implementation does not rely on the underlying
Operating System.
» Because Swing components are lightweight, their appearance is
determined by you, the programmer, and not by which platform
the program is running.
11

https://www.facebook.com/Oxus20
Converting Frame to JFrame
» The names of the Swing classes all begin with a capital

"J" , like JButton, JLabel, JFrame.
» For the most part, an AWT program can be converted

to a Swing program by adding a capital J to the class
names used in the source code and recompiling the
code.
12

https://www.facebook.com/Oxus20
Creating Windows
» The basic starting point of a GUI is the container because you need a
container before you can start laying out your components.
» The java.awt.Frame and javax.swing.JFrame classes are containers that
represent a basic window with a title bar and common windowing capabilities
such as resizing, minimizing, maximizing, and closing.
» When working with JFrame objects, there are basically three steps involved to
get a JFrame window to appear on the screen:
˃ Instantiate the JFrame object in memory.
˃ Give the JFrame object a size using setSize(), setBounds(), or pack().
˃ Make the Frame appear on the screen by invoking setVisible(true).
13

https://www.facebook.com/Oxus20
JFrame and Frame Constructors
The java.awt.Frame class has four constructors:
» public Frame() or JFrame()
˃

Creates a new frame with no message in the title bar.

» public Frame(String title) or JFrame(String title)
˃

Creates a new frame with the given String appearing in the title bar.

» public Frame(GraphicsConfiguration gc) or
JFrame(GraphicsConfiguration gc)
˃

Creates a frame with the specified GraphicsConfiguration of a screen device.

» public Frame(String title, GraphicsConfiguration gc) or JFrame(String
title, GraphicsConfiguration gc)
˃

Creates a frame with the specified title and GraphicsConfiguration.

https://www.facebook.com/Oxus20

14
javax.swing.JFrame Class
» The javax.swing.JFrame class represents a window similar to
Frame, except that JFrame adds support for the Swing
component architecture.
» However, a JFrame is different in terms of how components are
added to the Frame.
» A JFrame has three panes that components can be added to:
˃ a content pane
˃ a glass pane
˃ and a root pane.

» Typically, the content pane will contain all of the components of
the JFrame.
https://www.facebook.com/Oxus20

15
Simple Example of JFrame
import javax.swing.JFrame;
public class GUIDemo {
public static void main(String[] args) {
JFrame window = new JFrame(); //create frame in memory
window.setTitle( "Oxus20" );
// Set tittle to frame
window.setSize(300, 300);
// Set Size to frame
window.setLocationRelativeTo(null); //Set location to center of monitor
//let program to close
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
// Let frame to be visible on screen
}
}

16

https://www.facebook.com/Oxus20
END

17

https://www.facebook.com/Oxus20

Contenu connexe

Tendances

Tendances (20)

Servlets
ServletsServlets
Servlets
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
 
Event handling
Event handlingEvent handling
Event handling
 
JavaFX Presentation
JavaFX PresentationJavaFX Presentation
JavaFX Presentation
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread Synchronization
 
Swing
SwingSwing
Swing
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Java multi threading
Java multi threadingJava multi threading
Java multi threading
 
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 

En vedette

Java GUI PART II
Java GUI PART IIJava GUI PART II
Java GUI PART IIOXUS 20
 
JAVA GUI PART III
JAVA GUI PART IIIJAVA GUI PART III
JAVA GUI PART IIIOXUS 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 ReviewFernando Torres
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)Bilal Amjad
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Javayht4ever
 
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 Javababak danyal
 
USER INTERFACE DESIGN PPT
USER INTERFACE DESIGN PPTUSER INTERFACE DESIGN PPT
USER INTERFACE DESIGN PPTvicci4041
 
Utilisation de ZK avec Java - Retour d’expérience
Utilisation de ZK avec Java - Retour d’expérienceUtilisation de ZK avec Java - Retour d’expérience
Utilisation de ZK avec Java - Retour d’expériencelouschwartz
 
Oracle ADF : Vue d'ensemble
Oracle ADF : Vue d'ensembleOracle ADF : Vue d'ensemble
Oracle ADF : Vue d'ensembleANASYS
 
Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event HandlingJava Programming
 
java drag and drop and data transfer
java drag and drop and data transferjava drag and drop and data transfer
java drag and drop and data transferAnkit Desai
 
java swing programming
java swing programming java swing programming
java swing programming Ankit Desai
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in javaGoogle
 
Java Applet and Graphics
Java Applet and GraphicsJava Applet and Graphics
Java Applet and GraphicsOXUS 20
 
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton ClassesJava Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton ClassesOXUS 20
 
Conditional Statement
Conditional Statement Conditional Statement
Conditional Statement OXUS 20
 
Java Regular Expression PART I
Java Regular Expression PART IJava Regular Expression PART I
Java Regular Expression PART IOXUS 20
 

En vedette (20)

Java GUI PART II
Java GUI PART IIJava GUI PART II
Java GUI PART II
 
JAVA GUI PART III
JAVA GUI PART IIIJAVA GUI PART III
JAVA GUI PART III
 
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
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
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
 
Gui
GuiGui
Gui
 
USER INTERFACE DESIGN PPT
USER INTERFACE DESIGN PPTUSER INTERFACE DESIGN PPT
USER INTERFACE DESIGN PPT
 
Utilisation de ZK avec Java - Retour d’expérience
Utilisation de ZK avec Java - Retour d’expérienceUtilisation de ZK avec Java - Retour d’expérience
Utilisation de ZK avec Java - Retour d’expérience
 
Oracle ADF : Vue d'ensemble
Oracle ADF : Vue d'ensembleOracle ADF : Vue d'ensemble
Oracle ADF : Vue d'ensemble
 
Java swings
Java swingsJava swings
Java swings
 
Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event Handling
 
java drag and drop and data transfer
java drag and drop and data transferjava drag and drop and data transfer
java drag and drop and data transfer
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
 
java swing programming
java swing programming java swing programming
java swing programming
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
Java Applet and Graphics
Java Applet and GraphicsJava Applet and Graphics
Java Applet and Graphics
 
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton ClassesJava Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
 
Conditional Statement
Conditional Statement Conditional Statement
Conditional Statement
 
Java Regular Expression PART I
Java Regular Expression PART IJava Regular Expression PART I
Java Regular Expression PART I
 

Similaire à JAVA GUI PART I

GUI design using JAVAFX.ppt
GUI design using JAVAFX.pptGUI design using JAVAFX.ppt
GUI design using JAVAFX.pptTabassumMaktum
 
Workshop on Sencha Touch - Part 5 - UI components in sencha touch
Workshop on Sencha Touch - Part 5 - UI components in sencha touchWorkshop on Sencha Touch - Part 5 - UI components in sencha touch
Workshop on Sencha Touch - Part 5 - UI components in sencha touchNithya Sivakumar
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892renuka gavli
 
Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Mikkel Flindt Heisterberg
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Appletsamitksaha
 
Eo gaddis java_chapter_14_5e
Eo gaddis java_chapter_14_5eEo gaddis java_chapter_14_5e
Eo gaddis java_chapter_14_5eGina Bullock
 
Eo gaddis java_chapter_14_5e
Eo gaddis java_chapter_14_5eEo gaddis java_chapter_14_5e
Eo gaddis java_chapter_14_5eGina Bullock
 
Flutter vs Java Graphical User Interface Frameworks - text
Flutter vs Java Graphical User Interface Frameworks - textFlutter vs Java Graphical User Interface Frameworks - text
Flutter vs Java Graphical User Interface Frameworks - textToma Velev
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Windows Programming with Swing
Windows Programming with SwingWindows Programming with Swing
Windows Programming with Swingbackdoor
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorialsumitjoshi01
 

Similaire à JAVA GUI PART I (20)

GUI design using JAVAFX.ppt
GUI design using JAVAFX.pptGUI design using JAVAFX.ppt
GUI design using JAVAFX.ppt
 
Workshop on Sencha Touch - Part 5 - UI components in sencha touch
Workshop on Sencha Touch - Part 5 - UI components in sencha touchWorkshop on Sencha Touch - Part 5 - UI components in sencha touch
Workshop on Sencha Touch - Part 5 - UI components in sencha touch
 
GUI_part_1.pptx
GUI_part_1.pptxGUI_part_1.pptx
GUI_part_1.pptx
 
GUI JAVA PROG ~hmftj
GUI  JAVA PROG ~hmftjGUI  JAVA PROG ~hmftj
GUI JAVA PROG ~hmftj
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
 
Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
 
JAVA (UNIT 5)
JAVA (UNIT 5)JAVA (UNIT 5)
JAVA (UNIT 5)
 
Eo gaddis java_chapter_14_5e
Eo gaddis java_chapter_14_5eEo gaddis java_chapter_14_5e
Eo gaddis java_chapter_14_5e
 
Eo gaddis java_chapter_14_5e
Eo gaddis java_chapter_14_5eEo gaddis java_chapter_14_5e
Eo gaddis java_chapter_14_5e
 
Applet in java
Applet in javaApplet in java
Applet in java
 
Flutter vs Java Graphical User Interface Frameworks - text
Flutter vs Java Graphical User Interface Frameworks - textFlutter vs Java Graphical User Interface Frameworks - text
Flutter vs Java Graphical User Interface Frameworks - text
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Windows Programming with Swing
Windows Programming with SwingWindows Programming with Swing
Windows Programming with Swing
 
Jsf tutorial
Jsf tutorialJsf tutorial
Jsf tutorial
 
Report swings
Report swingsReport swings
Report swings
 
The java swing_tutorial
The java swing_tutorialThe java swing_tutorial
The java swing_tutorial
 
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)
 

Plus de OXUS 20

Java Arrays
Java ArraysJava Arrays
Java ArraysOXUS 20
 
Java Methods
Java MethodsJava Methods
Java MethodsOXUS 20
 
Structure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryStructure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryOXUS 20
 
PHP Basic and Fundamental Questions and Answers with Detail Explanation
PHP Basic and Fundamental Questions and Answers with Detail ExplanationPHP Basic and Fundamental Questions and Answers with Detail Explanation
PHP Basic and Fundamental Questions and Answers with Detail ExplanationOXUS 20
 
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersFundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersOXUS 20
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsOXUS 20
 
Create Splash Screen with Java Step by Step
Create Splash Screen with Java Step by StepCreate Splash Screen with Java Step by Step
Create Splash Screen with Java Step by StepOXUS 20
 
Fal-e-Hafez (Omens of Hafez) Cards in Persian using Java
Fal-e-Hafez (Omens of Hafez) Cards in Persian using JavaFal-e-Hafez (Omens of Hafez) Cards in Persian using Java
Fal-e-Hafez (Omens of Hafez) Cards in Persian using JavaOXUS 20
 
Web Design and Development Life Cycle and Technologies
Web Design and Development Life Cycle and TechnologiesWeb Design and Development Life Cycle and Technologies
Web Design and Development Life Cycle and TechnologiesOXUS 20
 
Java Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesJava Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesOXUS 20
 
Java Regular Expression PART II
Java Regular Expression PART IIJava Regular Expression PART II
Java Regular Expression PART IIOXUS 20
 
Java Guessing Game Number Tutorial
Java Guessing Game Number TutorialJava Guessing Game Number Tutorial
Java Guessing Game Number TutorialOXUS 20
 
JAVA Programming Questions and Answers PART III
JAVA Programming Questions and Answers PART IIIJAVA Programming Questions and Answers PART III
JAVA Programming Questions and Answers PART IIIOXUS 20
 
Object Oriented Programming with Real World Examples
Object Oriented Programming with Real World ExamplesObject Oriented Programming with Real World Examples
Object Oriented Programming with Real World ExamplesOXUS 20
 
Object Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non StaticObject Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non StaticOXUS 20
 

Plus de OXUS 20 (15)

Java Arrays
Java ArraysJava Arrays
Java Arrays
 
Java Methods
Java MethodsJava Methods
Java Methods
 
Structure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryStructure programming – Java Programming – Theory
Structure programming – Java Programming – Theory
 
PHP Basic and Fundamental Questions and Answers with Detail Explanation
PHP Basic and Fundamental Questions and Answers with Detail ExplanationPHP Basic and Fundamental Questions and Answers with Detail Explanation
PHP Basic and Fundamental Questions and Answers with Detail Explanation
 
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersFundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and Answers
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and Relationships
 
Create Splash Screen with Java Step by Step
Create Splash Screen with Java Step by StepCreate Splash Screen with Java Step by Step
Create Splash Screen with Java Step by Step
 
Fal-e-Hafez (Omens of Hafez) Cards in Persian using Java
Fal-e-Hafez (Omens of Hafez) Cards in Persian using JavaFal-e-Hafez (Omens of Hafez) Cards in Persian using Java
Fal-e-Hafez (Omens of Hafez) Cards in Persian using Java
 
Web Design and Development Life Cycle and Technologies
Web Design and Development Life Cycle and TechnologiesWeb Design and Development Life Cycle and Technologies
Web Design and Development Life Cycle and Technologies
 
Java Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesJava Unicode with Cool GUI Examples
Java Unicode with Cool GUI Examples
 
Java Regular Expression PART II
Java Regular Expression PART IIJava Regular Expression PART II
Java Regular Expression PART II
 
Java Guessing Game Number Tutorial
Java Guessing Game Number TutorialJava Guessing Game Number Tutorial
Java Guessing Game Number Tutorial
 
JAVA Programming Questions and Answers PART III
JAVA Programming Questions and Answers PART IIIJAVA Programming Questions and Answers PART III
JAVA Programming Questions and Answers PART III
 
Object Oriented Programming with Real World Examples
Object Oriented Programming with Real World ExamplesObject Oriented Programming with Real World Examples
Object Oriented Programming with Real World Examples
 
Object Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non StaticObject Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non Static
 

Dernier

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 

Dernier (20)

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 

JAVA GUI PART I

  • 2. Agenda » Introduction ˃ GUI (Graphical User Interface) ˃ Simple Example » AWT and Swing Package ˃ AWT ˃ Swing ˃ JFrame vs. Frame ˃ Simple Example 2 https://www.facebook.com/Oxus20
  • 3. Introduction » A Graphical User Interface (GUI) presents a user-friendly mechanism for interacting with an application. ˃ Gives an application a distinctive "look" and "feel". ˃ Consistent, intuitive user-interface components give users a sense of familiarity . ˃ Learn new applications more quickly and use them more productively. 3 https://www.facebook.com/Oxus20
  • 4. Introduction (cont..) » Built from GUI components. ˃ Sometimes called controls or widgets » User interacts via the mouse, the keyboard or another form of input, such as voice recognition. » IDEs ˃ Provide GUI design tools to specify a component's exact size and location in a visual manner by using the mouse. ˃ Generates the GUI code for you. ˃ Greatly simplifies creating GUIs, but each IDE has different capabilities and generates different code. 4 https://www.facebook.com/Oxus20
  • 5. Simple GUI-Based Input / Output with JOptionPane » Most applications use windows or dialog boxes (also called dialogs) to interact with the user. » JOptionPane (javax.swing package) provides prebuilt dialog boxes for input and output ˃ Displayed via static JOptionPane methods. » Next Example uses two input dialogs to get input from the user and a message dialog to display the sum of the given input. 5 https://www.facebook.com/Oxus20
  • 6. Simple GUI example import javax.swing.JOptionPane; public class Multiplier { public static void main(String[] args) { String firstNumber = JOptionPane.showInputDialog("Enter first number"); String secondNumber = JOptionPane.showInputDialog("Enter Second number"); int number1 = Integer.parseInt(firstNumber); int number2 = Integer.parseInt(secondNumber); int result = number1 * number2; JOptionPane.showMessageDialog(null, "The Multiply of " + number1 + " and " +number2 + " is " + result, "Result", JOptionPane.PLAIN_MESSAGE); } } 6 https://www.facebook.com/Oxus20
  • 8. More on GUI "AWT and Swing" 8 8 https://www.facebook.com/Oxus20
  • 9. AWT Vs. Swing » When Java was first released in 1995, it contained a GUI API referred to as the Abstract Windowing Toolkit (AWT). » The classes and interfaces of the AWT are in the java.awt package. » Aware of the need for a more robust API for creating GUI applications, Sun Microsystems teamed together with Netscape (and other industry partners) then created Swing package. https://www.facebook.com/Oxus20 9
  • 10. AWT Vs. Swing (cont.) » Swing is actually a part of the Java Foundation Classes (JFC). » The classes and interfaces of Swing are found in the javax.swing package. » AWT components are referred to as heavyweight components because their implementation relies heavily on the underlying Operating System. 10 https://www.facebook.com/Oxus20
  • 11. AWT Vs. Swing (cont.) » The look and feel of AWT components depend on the platform the program is running on. ˃ For example, an AWT button will look like a Windows button when the program is run on a Windows platform. » Swing components are referred to as lightweight components because their implementation does not rely on the underlying Operating System. » Because Swing components are lightweight, their appearance is determined by you, the programmer, and not by which platform the program is running. 11 https://www.facebook.com/Oxus20
  • 12. Converting Frame to JFrame » The names of the Swing classes all begin with a capital "J" , like JButton, JLabel, JFrame. » For the most part, an AWT program can be converted to a Swing program by adding a capital J to the class names used in the source code and recompiling the code. 12 https://www.facebook.com/Oxus20
  • 13. Creating Windows » The basic starting point of a GUI is the container because you need a container before you can start laying out your components. » The java.awt.Frame and javax.swing.JFrame classes are containers that represent a basic window with a title bar and common windowing capabilities such as resizing, minimizing, maximizing, and closing. » When working with JFrame objects, there are basically three steps involved to get a JFrame window to appear on the screen: ˃ Instantiate the JFrame object in memory. ˃ Give the JFrame object a size using setSize(), setBounds(), or pack(). ˃ Make the Frame appear on the screen by invoking setVisible(true). 13 https://www.facebook.com/Oxus20
  • 14. JFrame and Frame Constructors The java.awt.Frame class has four constructors: » public Frame() or JFrame() ˃ Creates a new frame with no message in the title bar. » public Frame(String title) or JFrame(String title) ˃ Creates a new frame with the given String appearing in the title bar. » public Frame(GraphicsConfiguration gc) or JFrame(GraphicsConfiguration gc) ˃ Creates a frame with the specified GraphicsConfiguration of a screen device. » public Frame(String title, GraphicsConfiguration gc) or JFrame(String title, GraphicsConfiguration gc) ˃ Creates a frame with the specified title and GraphicsConfiguration. https://www.facebook.com/Oxus20 14
  • 15. javax.swing.JFrame Class » The javax.swing.JFrame class represents a window similar to Frame, except that JFrame adds support for the Swing component architecture. » However, a JFrame is different in terms of how components are added to the Frame. » A JFrame has three panes that components can be added to: ˃ a content pane ˃ a glass pane ˃ and a root pane. » Typically, the content pane will contain all of the components of the JFrame. https://www.facebook.com/Oxus20 15
  • 16. Simple Example of JFrame import javax.swing.JFrame; public class GUIDemo { public static void main(String[] args) { JFrame window = new JFrame(); //create frame in memory window.setTitle( "Oxus20" ); // Set tittle to frame window.setSize(300, 300); // Set Size to frame window.setLocationRelativeTo(null); //Set location to center of monitor //let program to close window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setVisible(true); // Let frame to be visible on screen } } 16 https://www.facebook.com/Oxus20