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
4566a36c
Commit
4566a36c
authored
Jul 24, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rozmowa - Nispodzianka
parent
a47a3707
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
Rozmowa1.java
src/main/java/swing/zdarzenia/Rozmowa1.java
+16
-7
No files found.
src/main/java/swing/zdarzenia/Rozmowa1.java
View file @
4566a36c
...
@@ -4,6 +4,7 @@ import javax.swing.*;
...
@@ -4,6 +4,7 @@ import javax.swing.*;
import
java.awt.*
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.event.ActionListener
;
import
java.util.Random
;
public
class
Rozmowa1
{
public
class
Rozmowa1
{
private
static
final
Font
FONT
=
new
Font
(
"Arial"
,
Font
.
BOLD
,
32
);
private
static
final
Font
FONT
=
new
Font
(
"Arial"
,
Font
.
BOLD
,
32
);
...
@@ -49,13 +50,13 @@ public class Rozmowa1 {
...
@@ -49,13 +50,13 @@ public class Rozmowa1 {
panel
.
add
(
Box
.
createRigidArea
(
odstep
));
panel
.
add
(
Box
.
createRigidArea
(
odstep
));
//
JButton guzik2 = new JButton("Niespodzianka");
JButton
guzik2
=
new
JButton
(
"Niespodzianka"
);
//
guzik2.setFont(FONT);
guzik2
.
setFont
(
FONT
);
//
guzik2.setForeground(Color.RED);
guzik2
.
setForeground
(
Color
.
RED
);
//
guzik2.setMaximumSize(new Dimension(Integer.MAX_VALUE, 30));
guzik2
.
setMaximumSize
(
new
Dimension
(
Integer
.
MAX_VALUE
,
30
));
//
panel.add(guzik2);
panel
.
add
(
guzik2
);
//
//
panel.add(Box.createRigidArea(odstep));
panel
.
add
(
Box
.
createRigidArea
(
odstep
));
okno
.
pack
();
okno
.
pack
();
// Aby naciśnięcie guzika spowodowało rekację, do guzika trzeba przekazać "listenera",
// Aby naciśnięcie guzika spowodowało rekację, do guzika trzeba przekazać "listenera",
...
@@ -81,6 +82,14 @@ public class Rozmowa1 {
...
@@ -81,6 +82,14 @@ public class Rozmowa1 {
powitanie
.
setForeground
(
Color
.
MAGENTA
);
powitanie
.
setForeground
(
Color
.
MAGENTA
);
});
});
Random
random
=
new
Random
();
guzik2
.
addActionListener
(
evt
->
{
okno
.
getContentPane
().
setBackground
(
new
Color
(
random
.
nextInt
(
0x1000000
)));
int
x
=
okno
.
getX
()
+
random
.
nextInt
(
400
)
-
200
;
int
y
=
okno
.
getY
()
+
random
.
nextInt
(
400
)
-
200
;
okno
.
setLocation
(
x
,
y
);
});
okno
.
setVisible
(
true
);
okno
.
setVisible
(
true
);
System
.
out
.
println
(
"okno wyświetlone, koniec main"
);
System
.
out
.
println
(
"okno wyświetlone, koniec main"
);
}
}
...
...
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