SlideShare a Scribd company logo
» 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

More Related Content

What's hot

Event handling
Event handlingEvent handling
Event handling
swapnac12
 
Types of exceptions
Types of exceptionsTypes of exceptions
Types of exceptionsmyrajendra
 
Java servlets
Java servletsJava servlets
Java servlets
Mukesh Tekwani
 
Servlets
ServletsServlets
Java swing
Java swingJava swing
Java swing
ssuser3a47cb
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
priya Nithya
 
Asynchronous programming
Asynchronous programmingAsynchronous programming
Asynchronous programming
Filip Ekberg
 
JavaScript Engines and Event Loop
JavaScript Engines and Event Loop JavaScript Engines and Event Loop
JavaScript Engines and Event Loop
Tapan B.K.
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
Vipin Yadav
 
Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
soumyaharitha
 
Servlets
ServletsServlets
Servlets
ZainabNoorGul
 
C# Framework class library
C# Framework class libraryC# Framework class library
C# Framework class library
Prem Kumar Badri
 
Threads And Synchronization in C#
Threads And Synchronization in C#Threads And Synchronization in C#
Threads And Synchronization in C#
Rizwan Ali
 
Servlets
ServletsServlets
Java awt
Java awtJava awt
Java awt
Arati Gadgil
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
Dhruvin Nakrani
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 

What's hot (20)

Event handling
Event handlingEvent handling
Event handling
 
Types of exceptions
Types of exceptionsTypes of exceptions
Types of exceptions
 
Java servlets
Java servletsJava servlets
Java servlets
 
Servlets
ServletsServlets
Servlets
 
Java swing
Java swingJava swing
Java swing
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
Asynchronous programming
Asynchronous programmingAsynchronous programming
Asynchronous programming
 
JavaScript Engines and Event Loop
JavaScript Engines and Event Loop JavaScript Engines and Event Loop
JavaScript Engines and Event Loop
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
 
Event handling
Event handlingEvent handling
Event handling
 
Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
 
Servlets
ServletsServlets
Servlets
 
C# Framework class library
C# Framework class libraryC# Framework class library
C# Framework class library
 
Threads And Synchronization in C#
Threads And Synchronization in C#Threads And Synchronization in C#
Threads And Synchronization in C#
 
Servlets
ServletsServlets
Servlets
 
Java awt
Java awtJava awt
Java awt
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
 
Java I/O
Java I/OJava I/O
Java I/O
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 

Viewers also liked

JAVA GUI PART III
JAVA GUI PART IIIJAVA GUI PART III
JAVA GUI PART III
OXUS 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
 
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 Java
yht4ever
 
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
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
PRN USM
 
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érience
louschwartz
 
Oracle ADF : Vue d'ensemble
Oracle ADF : Vue d'ensembleOracle ADF : Vue d'ensemble
Oracle ADF : Vue d'ensemble
ANASYS
 
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 transfer
Ankit Desai
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
Shehrevar Davierwala
 
java swing programming
java swing programming java swing programming
java swing programming
Ankit Desai
 
Java Applet and Graphics
Java Applet and GraphicsJava Applet and Graphics
Java Applet and Graphics
OXUS 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 Classes
OXUS 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 I
OXUS 20
 
Everything about Object Oriented Programming
Everything about Object Oriented ProgrammingEverything about Object Oriented Programming
Everything about Object Oriented Programming
Abdul Rahman Sherzad
 

Viewers also liked (20)

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
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
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
 
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
 
Everything about Object Oriented Programming
Everything about Object Oriented ProgrammingEverything about Object Oriented Programming
Everything about Object Oriented Programming
 

Similar to JAVA GUI PART I

GUI design using JAVAFX.ppt
GUI design using JAVAFX.pptGUI design using JAVAFX.ppt
GUI design using JAVAFX.ppt
TabassumMaktum
 
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
Nithya Sivakumar
 
GUI_part_1.pptx
GUI_part_1.pptxGUI_part_1.pptx
GUI_part_1.pptx
Parasuraman43
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
renuka 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
 
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
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
amitksaha
 
JAVA (UNIT 5)
JAVA (UNIT 5)JAVA (UNIT 5)
JAVA (UNIT 5)
SURBHI SAROHA
 
Eo gaddis java_chapter_14_5e
Eo gaddis java_chapter_14_5eEo gaddis java_chapter_14_5e
Eo gaddis java_chapter_14_5e
Gina Bullock
 
Eo gaddis java_chapter_14_5e
Eo gaddis java_chapter_14_5eEo gaddis java_chapter_14_5e
Eo gaddis java_chapter_14_5e
Gina Bullock
 
Applet in java
Applet in javaApplet in java
Applet in java
Jancypriya M
 
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
Toma Velev
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
Yiguang Hu
 
Windows Programming with Swing
Windows Programming with SwingWindows Programming with Swing
Windows Programming with Swingbackdoor
 
Swing
SwingSwing
Jsf tutorial
Jsf tutorialJsf tutorial
Jsf tutorial
Edress Oryakhail
 
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)
 

Similar to 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
 
Swing
SwingSwing
Swing
 
Jsf tutorial
Jsf tutorialJsf tutorial
Jsf tutorial
 
Report swings
Report swingsReport swings
Report swings
 
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)
 

More from OXUS 20

Java Arrays
Java ArraysJava Arrays
Java Arrays
OXUS 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 – Theory
OXUS 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 Explanation
OXUS 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 Answers
OXUS 20
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and Relationships
OXUS 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 Step
OXUS 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 Java
OXUS 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 Technologies
OXUS 20
 
Java Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesJava Unicode with Cool GUI Examples
Java Unicode with Cool GUI Examples
OXUS 20
 
Java Regular Expression PART II
Java Regular Expression PART IIJava Regular Expression PART II
Java Regular Expression PART II
OXUS 20
 
Java Guessing Game Number Tutorial
Java Guessing Game Number TutorialJava Guessing Game Number Tutorial
Java Guessing Game Number Tutorial
OXUS 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 Examples
OXUS 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 Static
OXUS 20
 

More from 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
 

Recently uploaded

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 

Recently uploaded (20)

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 

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