SlideShare a Scribd company logo
3
Most read
4
Most read
5
Most read
<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 (20)

PPT
C# basics
Dinesh kumar
 
PPT
Web Engineering
Deniz Kılınç
 
PPTX
Formal Approaches to SQA.pptx
KarthigaiSelviS3
 
PPTX
Java string handling
GaneshKumarKanthiah
 
PDF
Generics
Ravi_Kant_Sahu
 
PPTX
Lecture - 2 Environment setup & JDK, JRE, JVM
manish kumar
 
PPTX
Error managing and exception handling in java
Andhra University
 
PPTX
Java swing
Apurbo Datta
 
PPT
PHP variables
Siddique Ibrahim
 
PPTX
Object model
James Wong
 
PPS
Java rmi
kamal kotecha
 
PPT
Object Oriented Analysis and Design
Haitham El-Ghareeb
 
PPSX
Php and MySQL
Tiji Thomas
 
PPTX
Error handling and debugging in vb
Salim M
 
PPTX
Strings in Java
Abhilash Nair
 
PPTX
Characteristics of OOPS
abhishek kumar
 
PDF
Java Programming
Anjan Mahanta
 
PPT
Uml in software engineering
Mubashir Jutt
 
PDF
Introduction to java (revised)
Sujit Majety
 
PPT
Java
s4al_com
 
C# basics
Dinesh kumar
 
Web Engineering
Deniz Kılınç
 
Formal Approaches to SQA.pptx
KarthigaiSelviS3
 
Java string handling
GaneshKumarKanthiah
 
Generics
Ravi_Kant_Sahu
 
Lecture - 2 Environment setup & JDK, JRE, JVM
manish kumar
 
Error managing and exception handling in java
Andhra University
 
Java swing
Apurbo Datta
 
PHP variables
Siddique Ibrahim
 
Object model
James Wong
 
Java rmi
kamal kotecha
 
Object Oriented Analysis and Design
Haitham El-Ghareeb
 
Php and MySQL
Tiji Thomas
 
Error handling and debugging in vb
Salim M
 
Strings in Java
Abhilash Nair
 
Characteristics of OOPS
abhishek kumar
 
Java Programming
Anjan Mahanta
 
Uml in software engineering
Mubashir Jutt
 
Introduction to java (revised)
Sujit Majety
 
Java
s4al_com
 

Viewers also liked (7)

PDF
Apresentação-Resumo sobre o Java Swing.
Gabriel Jesus
 
ODP
Java 07 Entrada Dados
Regis Magalhães
 
PPT
Java Swing
Shraddha
 
PDF
java swing tutorial for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PPT
java swing
vannarith
 
PPTX
Joptionpane
pauslt
 
PDF
Joptionpane
PAULO Moreira
 
Apresentação-Resumo sobre o Java Swing.
Gabriel Jesus
 
Java 07 Entrada Dados
Regis Magalhães
 
Java Swing
Shraddha
 
java swing tutorial for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
java swing
vannarith
 
Joptionpane
pauslt
 
Joptionpane
PAULO Moreira
 
Ad

Recently uploaded (20)

PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
community health nursing question paper 2.pdf
Prince kumar
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Ad

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