Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_mszczonow_1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
alx_mszczonow_1
Commits
72f02db4
Commit
72f02db4
authored
Jun 26, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JOptionPane
parent
c3a202a7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
RodzajeOkien.java
src/main/java/p01_okna_dialogowe/RodzajeOkien.java
+40
-0
No files found.
src/main/java/p01_okna_dialogowe/RodzajeOkien.java
0 → 100644
View file @
72f02db4
package
p01_okna_dialogowe
;
import
java.time.LocalDateTime
;
import
javax.swing.JOptionPane
;
public
class
RodzajeOkien
{
public
static
void
main
(
String
[]
args
)
{
JOptionPane
.
showMessageDialog
(
null
,
"To jest zwykły MessageDialog"
);
JOptionPane
.
showMessageDialog
(
null
,
"To jest MessageDialog typu WARNING"
,
"Uwaga"
,
JOptionPane
.
WARNING_MESSAGE
);
// są też inne typy: PLAIN_MESSAGE, INFORMATION_MESSAGE, QUESTION_MESSAGE, WARNING_MESSAGE, ERROR_MESSAGE
String
cos
=
JOptionPane
.
showInputDialog
(
"To jest inputDialog.\nNapisz coś:"
);
String
data
=
JOptionPane
.
showInputDialog
(
"To jest inputDialog z początkową wartością."
,
LocalDateTime
.
now
());
// Rozbudowana wersja showInputDialog pozwala wybrać wartość z rozwijanej listy
// Należy przekazać tablicę wartości do wyboru
String
[]
opcje
=
{
"wiosna"
,
"lato"
,
"jesień"
,
"zima"
};
String
poraRoku
=
(
String
)
JOptionPane
.
showInputDialog
(
null
,
"Którą porę roku lubisz najbardziej?"
,
"Pytanie"
,
JOptionPane
.
QUESTION_MESSAGE
,
null
,
opcje
,
"jesień"
);
int
pora2
=
JOptionPane
.
showOptionDialog
(
null
,
"A której pory nie lubisz?"
,
"Pytanie 2"
,
0
,
JOptionPane
.
QUESTION_MESSAGE
,
null
,
opcje
,
"zima"
);
// dostajemy numer wybranej opcji, od 0
int
wybor
=
JOptionPane
.
showConfirmDialog
(
null
,
"Czy chcesz "
+
cos
+
" o godzinie "
+
data
+
"?"
);
switch
(
wybor
)
{
case
JOptionPane
.
YES_OPTION
->
JOptionPane
.
showMessageDialog
(
null
,
"TAK"
);
case
JOptionPane
.
NO_OPTION
->
JOptionPane
.
showMessageDialog
(
null
,
"NO"
);
case
JOptionPane
.
CANCEL_OPTION
->
JOptionPane
.
showMessageDialog
(
null
,
"Cancel"
);
default
->
JOptionPane
.
showMessageDialog
(
null
,
"Inna wartość: "
+
wybor
);
// zamknięcie okna daje wynik -1 czyli CLOSED_OPTION
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment