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

PDF
Python programming : Threads
PDF
Les bases de l'HTML / CSS
PDF
Manual de instalación de pentaho para windows 7
PPT
Heap sort
PDF
Initiation html css
PDF
BEM it! Introduction to BEM methodology
PPT
Java Script Object Notation (JSON)
PPTX
CS8391-Data Structures Unit 2
Python programming : Threads
Les bases de l'HTML / CSS
Manual de instalación de pentaho para windows 7
Heap sort
Initiation html css
BEM it! Introduction to BEM methodology
Java Script Object Notation (JSON)
CS8391-Data Structures Unit 2

What's hot (20)

PPTX
1 03 - CSS Introduction
PPTX
PROLOG: Database Manipulation In Prolog
PPTX
Css font properties
PDF
Webscale PostgreSQL - JSONB and Horizontal Scaling Strategies
PDF
Algorithm and Data Structure - Queue
PPTX
Html tables, forms and audio video
PPTX
Vector class in C++
PPTX
Markdown – An Introduction
PDF
ΓΛΩΣΣΑ C++ - ΜΑΘΗΜΑ 3 - ΚΛΑΣΕΙΣ ΚΑΙ ΔΕΙΚΤΕΣ
PPTX
Introduction to JSX
DOCX
系統程式 -- 第 8 章 編譯器
PDF
PPTX
Data Structures - Lecture 8 [Sorting Algorithms]
PPT
Advanced Cascading Style Sheets
PPTX
PPTX
(Fast) Introduction to HTML & CSS
PPTX
Python presentation
PDF
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
PPTX
HTML (Hyper Text Markup Language)
1 03 - CSS Introduction
PROLOG: Database Manipulation In Prolog
Css font properties
Webscale PostgreSQL - JSONB and Horizontal Scaling Strategies
Algorithm and Data Structure - Queue
Html tables, forms and audio video
Vector class in C++
Markdown – An Introduction
ΓΛΩΣΣΑ C++ - ΜΑΘΗΜΑ 3 - ΚΛΑΣΕΙΣ ΚΑΙ ΔΕΙΚΤΕΣ
Introduction to JSX
系統程式 -- 第 8 章 編譯器
Data Structures - Lecture 8 [Sorting Algorithms]
Advanced Cascading Style Sheets
(Fast) Introduction to HTML & CSS
Python presentation
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
HTML (Hyper Text Markup Language)
Ad

Viewers also liked (7)

PDF
Apresentação-Resumo sobre o Java Swing.
ODP
Java 07 Entrada Dados
PPT
Java Swing
PDF
java swing tutorial for beginners(java programming tutorials)
PPT
java swing
PPTX
Joptionpane
PDF
Joptionpane
Apresentação-Resumo sobre o Java Swing.
Java 07 Entrada Dados
Java Swing
java swing tutorial for beginners(java programming tutorials)
java swing
Joptionpane
Joptionpane
Ad

Recently uploaded (20)

PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Lesson notes of climatology university.
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
IGGE1 Understanding the Self1234567891011
PDF
Indian roads congress 037 - 2012 Flexible pavement
PPTX
Cell Types and Its function , kingdom of life
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
1_English_Language_Set_2.pdf probationary
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
advance database management system book.pdf
PDF
Classroom Observation Tools for Teachers
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
Supply Chain Operations Speaking Notes -ICLT Program
Lesson notes of climatology university.
UNIT III MENTAL HEALTH NURSING ASSESSMENT
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
IGGE1 Understanding the Self1234567891011
Indian roads congress 037 - 2012 Flexible pavement
Cell Types and Its function , kingdom of life
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
LDMMIA Reiki Yoga Finals Review Spring Summer
Practical Manual AGRO-233 Principles and Practices of Natural Farming
A systematic review of self-coping strategies used by university students to ...
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
What if we spent less time fighting change, and more time building what’s rig...
1_English_Language_Set_2.pdf probationary
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
advance database management system book.pdf
Classroom Observation Tools for Teachers

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