SlideShare a Scribd company logo
<1> ♋ Bero
JOptionPane
Message, input,
and confirm dialogs
<2> ♋ Bero
 JOptionPane can be used to create different types of dialogs:
 Firstly…
import javax.swing.JOptionPane;
JOptionPane
Message dialog
Input dialog
Confirm dialog
<3> ♋ Bero
1) Message dialogs:
There are several overloaded versions of showMessageDialog( )
1.1) JOptionPane.showMessageDialog(Component, Message);
Example:
JOptionPane.showMessageDialog(null, “Hello world”);
1.2) JOptionPane.showMessageDialog(Component, Message, Title,
MessageType);
Example:
JOptionPane.showMessageDialog(null, “Hello world”, “My Message”,
JOptionPane.PLAIN_MESSAGE);
The graphical component in
which the message dialog
will be displayed within.
The message that will
be displayed.
Null indicates
message will appear
in the centre of the
screen.
A string
representing the
title of the message.
The icon of the message changes
according to type passed.
<4> ♋ Bero
 Message icon Types:
Example:
JOptionPane.showMessageDialog(null, “Hello world”, “My Message”,
JOptionPane.WARNING_MESSAGE);
The numeric value of the icon can be passed as a parameter as well.
Example:
JOptionPane.showMessageDialog(null, “Hello world”, “My Message”, 0);
<5> ♋ Bero
2) Input dialogs:
- Overloaded forms of showInputDialog( ):
2.1) String x = JOptionPane.showInputDialog(“prompt message”);
Example:
String x = JOptionPane.showInputDialog(“Enter a
value: ”);
2.2) String x = JOptionPane.showInputDialog(“message”, InitialValue);
Example:
String x = JOptionPane.showInputDialog(“Enter a value: ”, 0);
2.3) String x = JOptionPane.showInputDialog(Component, “message”,
“Title”, IconType);
Example:
String x = JOptionPane.showInputDialog(null, “Enter a value: ”, “Input
value”, 1);
A variable of type string to
hold the value entered by the
user.
Message that will appear on the dialog.
<6> ♋ Bero
3) Confirm dialogs:
- Overloaded forms of showConfirmDialog( ):
3.1) int y = JOptionPane.showConfirmDialog(Component, “Message”);
Example:
int y = JOptionPane.showConfirmDialog(null, “Are you sure?”);
3.2) int y = JOptionPane.showConfirmDialog(Component, “Message”,
“Title”, OptionType);
Example:
int y = JOptionPane.showConfirmDialog(null, “Are you sure?”,
“Confirm”, JOptionPane.YES_NO_OPTION);
Holds a value depending on the user’s
choice (yes (0), no (1), or cancel (2)).
 Buttons appearing on dialog:
- YES_NO_CANCEL_OPTION
- YES_NO_OPTION
- YES_OPTION

More Related Content

What's hot

Spring Boot
Spring BootSpring Boot
Spring Boot
HongSeong Jeon
 
Net framework
Net frameworkNet framework
Net framework
Saiteja Kaparthi
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
WebSockets with Spring 4
WebSockets with Spring 4WebSockets with Spring 4
WebSockets with Spring 4
Sergi Almar i Graupera
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
Rajkumarsoy
 
Accessibility Support Baseline: Balancing User Needs Against Test Effort
Accessibility Support Baseline: Balancing User Needs Against Test EffortAccessibility Support Baseline: Balancing User Needs Against Test Effort
Accessibility Support Baseline: Balancing User Needs Against Test Effort
Aidan Tierney
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Purbarun Chakrabarti
 
JPA and Hibernate
JPA and HibernateJPA and Hibernate
JPA and Hibernate
elliando dias
 
Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for Designers
R. Sosa
 
Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)
UC San Diego
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 
Spring boot
Spring bootSpring boot
Spring boot
Bhagwat Kumar
 
JavaFX Overview
JavaFX OverviewJavaFX Overview
JavaFX Overview
José Maria Silveira Neto
 
REST-API overview / concepts
REST-API overview / conceptsREST-API overview / concepts
REST-API overview / concepts
Patrick Savalle
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Example
kamal kotecha
 
Ppt of socket
Ppt of socketPpt of socket
Ppt of socket
Amandeep Kaur
 
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMJava Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
shamnasain
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfBasics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdf
Knoldus Inc.
 
Angular Lifecycle Hooks
Angular Lifecycle HooksAngular Lifecycle Hooks
Angular Lifecycle Hooks
Squash Apps Pvt Ltd
 
Java servlets
Java servletsJava servlets
Java servlets
lopjuan
 

What's hot (20)

Spring Boot
Spring BootSpring Boot
Spring Boot
 
Net framework
Net frameworkNet framework
Net framework
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
 
WebSockets with Spring 4
WebSockets with Spring 4WebSockets with Spring 4
WebSockets with Spring 4
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Accessibility Support Baseline: Balancing User Needs Against Test Effort
Accessibility Support Baseline: Balancing User Needs Against Test EffortAccessibility Support Baseline: Balancing User Needs Against Test Effort
Accessibility Support Baseline: Balancing User Needs Against Test Effort
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
JPA and Hibernate
JPA and HibernateJPA and Hibernate
JPA and Hibernate
 
Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for Designers
 
Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Spring boot
Spring bootSpring boot
Spring boot
 
JavaFX Overview
JavaFX OverviewJavaFX Overview
JavaFX Overview
 
REST-API overview / concepts
REST-API overview / conceptsREST-API overview / concepts
REST-API overview / concepts
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Example
 
Ppt of socket
Ppt of socketPpt of socket
Ppt of socket
 
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMJava Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfBasics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdf
 
Angular Lifecycle Hooks
Angular Lifecycle HooksAngular Lifecycle Hooks
Angular Lifecycle Hooks
 
Java servlets
Java servletsJava servlets
Java servlets
 

Viewers also liked

Apresentação-Resumo sobre o Java Swing.
Apresentação-Resumo sobre o Java Swing.Apresentação-Resumo sobre o Java Swing.
Apresentação-Resumo sobre o Java Swing.
Gabriel Jesus
 
Java 07 Entrada Dados
Java 07 Entrada DadosJava 07 Entrada Dados
Java 07 Entrada Dados
Regis Magalhães
 
Java Swing
Java SwingJava Swing
Java Swing
Shraddha
 
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
 
Joptionpane
JoptionpaneJoptionpane
Joptionpane
pauslt
 
Joptionpane
JoptionpaneJoptionpane
Joptionpane
PAULO Moreira
 

Viewers also liked (7)

Apresentação-Resumo sobre o Java Swing.
Apresentação-Resumo sobre o Java Swing.Apresentação-Resumo sobre o Java Swing.
Apresentação-Resumo sobre o Java Swing.
 
Java 07 Entrada Dados
Java 07 Entrada DadosJava 07 Entrada Dados
Java 07 Entrada Dados
 
Java Swing
Java SwingJava Swing
Java Swing
 
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)
 
java swing
java swingjava swing
java swing
 
Joptionpane
JoptionpaneJoptionpane
Joptionpane
 
Joptionpane
JoptionpaneJoptionpane
Joptionpane
 

Recently uploaded

C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 

Recently uploaded (20)

C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 

Java JOptionPane tutorial - Message, input, and confirm dialogs

  • 1. <1> ♋ Bero JOptionPane Message, input, and confirm dialogs
  • 2. <2> ♋ Bero  JOptionPane can be used to create different types of dialogs:  Firstly… import javax.swing.JOptionPane; JOptionPane Message dialog Input dialog Confirm dialog
  • 3. <3> ♋ Bero 1) Message dialogs: There are several overloaded versions of showMessageDialog( ) 1.1) JOptionPane.showMessageDialog(Component, Message); Example: JOptionPane.showMessageDialog(null, “Hello world”); 1.2) JOptionPane.showMessageDialog(Component, Message, Title, MessageType); Example: JOptionPane.showMessageDialog(null, “Hello world”, “My Message”, JOptionPane.PLAIN_MESSAGE); The graphical component in which the message dialog will be displayed within. The message that will be displayed. Null indicates message will appear in the centre of the screen. A string representing the title of the message. The icon of the message changes according to type passed.
  • 4. <4> ♋ Bero  Message icon Types: Example: JOptionPane.showMessageDialog(null, “Hello world”, “My Message”, JOptionPane.WARNING_MESSAGE); The numeric value of the icon can be passed as a parameter as well. Example: JOptionPane.showMessageDialog(null, “Hello world”, “My Message”, 0);
  • 5. <5> ♋ Bero 2) Input dialogs: - Overloaded forms of showInputDialog( ): 2.1) String x = JOptionPane.showInputDialog(“prompt message”); Example: String x = JOptionPane.showInputDialog(“Enter a value: ”); 2.2) String x = JOptionPane.showInputDialog(“message”, InitialValue); Example: String x = JOptionPane.showInputDialog(“Enter a value: ”, 0); 2.3) String x = JOptionPane.showInputDialog(Component, “message”, “Title”, IconType); Example: String x = JOptionPane.showInputDialog(null, “Enter a value: ”, “Input value”, 1); A variable of type string to hold the value entered by the user. Message that will appear on the dialog.
  • 6. <6> ♋ Bero 3) Confirm dialogs: - Overloaded forms of showConfirmDialog( ): 3.1) int y = JOptionPane.showConfirmDialog(Component, “Message”); Example: int y = JOptionPane.showConfirmDialog(null, “Are you sure?”); 3.2) int y = JOptionPane.showConfirmDialog(Component, “Message”, “Title”, OptionType); Example: int y = JOptionPane.showConfirmDialog(null, “Are you sure?”, “Confirm”, JOptionPane.YES_NO_OPTION); Holds a value depending on the user’s choice (yes (0), no (1), or cancel (2)).  Buttons appearing on dialog: - YES_NO_CANCEL_OPTION - YES_NO_OPTION - YES_OPTION