Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20231104-KursPodstawowyALX
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
20231104-KursPodstawowyALX
Commits
fda66b83
Commit
fda66b83
authored
Jan 07, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
layout managery
parent
892538de
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
229 additions
and
0 deletions
+229
-0
Okno3b.java
src/main/java/p30_swing/podstawy/Okno3b.java
+39
-0
Okno3c_Border.java
src/main/java/p30_swing/podstawy/Okno3c_Border.java
+45
-0
Okno3d_Flow.java
src/main/java/p30_swing/podstawy/Okno3d_Flow.java
+47
-0
Okno3e_Box.java
src/main/java/p30_swing/podstawy/Okno3e_Box.java
+47
-0
Okno3f_Grid.java
src/main/java/p30_swing/podstawy/Okno3f_Grid.java
+51
-0
No files found.
src/main/java/p30_swing/podstawy/Okno3b.java
0 → 100644
View file @
fda66b83
package
p30_swing
.
podstawy
;
import
java.awt.Color
;
import
java.awt.Font
;
import
javax.swing.JButton
;
import
javax.swing.JFrame
;
import
javax.swing.JLabel
;
public
class
Okno3b
{
public
static
void
main
(
String
[]
args
)
{
JFrame
frame
=
new
JFrame
(
"Nasza apka"
);
frame
.
setSize
(
600
,
400
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
JLabel
label1
=
new
JLabel
(
"Hello world"
);
label1
.
setHorizontalAlignment
(
JLabel
.
CENTER
);
// label1.setVerticalAlignment(JLabel.TOP);
label1
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
40
));
label1
.
setForeground
(
Color
.
BLUE
);
label1
.
setOpaque
(
true
);
label1
.
setBackground
(
Color
.
YELLOW
);
frame
.
add
(
label1
);
// Domyślnym LayoutManagerem jest BorderLayout.
// On potrafi umieścić komponent w środku lub przy jednej z krawędzi określonej słowami "North", "South"...
JButton
button1
=
new
JButton
(
"Guzik 1"
);
button1
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
32
));
frame
.
add
(
button1
,
"North"
);
JButton
button2
=
new
JButton
(
"Guzik 2"
);
button2
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
32
));
frame
.
add
(
button2
,
"South"
);
frame
.
setVisible
(
true
);
}
}
src/main/java/p30_swing/podstawy/Okno3c_Border.java
0 → 100644
View file @
fda66b83
package
p30_swing
.
podstawy
;
import
java.awt.BorderLayout
;
import
java.awt.Color
;
import
java.awt.Font
;
import
java.awt.LayoutManager
;
import
javax.swing.JButton
;
import
javax.swing.JFrame
;
import
javax.swing.JLabel
;
public
class
Okno3c_Border
{
public
static
void
main
(
String
[]
args
)
{
JFrame
frame
=
new
JFrame
(
"Nasza apka"
);
frame
.
setSize
(
600
,
400
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
// Tutaj BorderLayout wskazujemy jawnie. W parametrach można podać odstęp
// LayoutManager layout = new BorderLayout();
LayoutManager
layout
=
new
BorderLayout
(
10
,
25
);
frame
.
setLayout
(
layout
);
JLabel
label1
=
new
JLabel
(
"Hello world"
);
label1
.
setHorizontalAlignment
(
JLabel
.
CENTER
);
// label1.setVerticalAlignment(JLabel.TOP);
label1
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
40
));
label1
.
setForeground
(
Color
.
BLUE
);
label1
.
setOpaque
(
true
);
label1
.
setBackground
(
Color
.
YELLOW
);
frame
.
add
(
label1
);
JButton
button1
=
new
JButton
(
"Guzik 1"
);
button1
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
32
));
// frame.add(button1, "North");
frame
.
add
(
button1
,
BorderLayout
.
NORTH
);
JButton
button2
=
new
JButton
(
"Guzik 2"
);
button2
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
32
));
frame
.
add
(
button2
,
BorderLayout
.
SOUTH
);
frame
.
setVisible
(
true
);
}
}
src/main/java/p30_swing/podstawy/Okno3d_Flow.java
0 → 100644
View file @
fda66b83
package
p30_swing
.
podstawy
;
import
java.awt.Color
;
import
java.awt.FlowLayout
;
import
java.awt.Font
;
import
java.awt.LayoutManager
;
import
javax.swing.JButton
;
import
javax.swing.JFrame
;
import
javax.swing.JLabel
;
public
class
Okno3d_Flow
{
public
static
void
main
(
String
[]
args
)
{
JFrame
frame
=
new
JFrame
(
"Nasza apka"
);
frame
.
setSize
(
600
,
400
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
// LayoutManager layout = new FlowLayout();
LayoutManager
layout
=
new
FlowLayout
(
FlowLayout
.
CENTER
,
20
,
10
);
frame
.
setLayout
(
layout
);
JLabel
label1
=
new
JLabel
(
"Hello world"
);
label1
.
setHorizontalAlignment
(
JLabel
.
CENTER
);
// label1.setVerticalAlignment(JLabel.TOP);
label1
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
40
));
label1
.
setForeground
(
Color
.
BLUE
);
label1
.
setOpaque
(
true
);
label1
.
setBackground
(
Color
.
YELLOW
);
frame
.
add
(
label1
);
JLabel
label2
=
new
JLabel
(
"Ala ma kota"
);
label2
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
40
));
frame
.
add
(
label2
);
JButton
button1
=
new
JButton
(
"Guzik 1"
);
button1
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
32
));
frame
.
add
(
button1
);
JButton
button2
=
new
JButton
(
"Guzik 2"
);
button2
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
32
));
frame
.
add
(
button2
);
frame
.
setVisible
(
true
);
}
}
src/main/java/p30_swing/podstawy/Okno3e_Box.java
0 → 100644
View file @
fda66b83
package
p30_swing
.
podstawy
;
import
java.awt.Color
;
import
java.awt.Font
;
import
java.awt.LayoutManager
;
import
javax.swing.BoxLayout
;
import
javax.swing.JButton
;
import
javax.swing.JFrame
;
import
javax.swing.JLabel
;
public
class
Okno3e_Box
{
// Tu używam już innego layoutu - BoxLayout
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Początek main"
);
JFrame
okno
=
new
JFrame
(
"Nasza apka"
);
okno
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
okno
.
setSize
(
600
,
400
);
LayoutManager
layout
=
new
BoxLayout
(
okno
.
getContentPane
(),
BoxLayout
.
Y_AXIS
);
okno
.
setLayout
(
layout
);
JLabel
label1
=
new
JLabel
(
"Ala ma kota"
);
label1
.
setHorizontalAlignment
(
JLabel
.
CENTER
);
label1
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
30
));
label1
.
setForeground
(
Color
.
RED
);
okno
.
add
(
label1
);
JLabel
label2
=
new
JLabel
(
"Ola ma psa"
);
label2
.
setHorizontalAlignment
(
JLabel
.
RIGHT
);
label2
.
setFont
(
new
Font
(
"Arial"
,
Font
.
ITALIC
,
30
));
label2
.
setForeground
(
Color
.
BLUE
);
okno
.
add
(
label2
);
JButton
button1
=
new
JButton
(
"Kliknij mnie"
);
button1
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
|
Font
.
ITALIC
,
30
));
button1
.
setForeground
(
Color
.
GREEN
);
okno
.
add
(
button1
);
okno
.
setVisible
(
true
);
System
.
out
.
println
(
"Koniec main"
);
}
}
src/main/java/p30_swing/podstawy/Okno3f_Grid.java
0 → 100644
View file @
fda66b83
package
p30_swing
.
podstawy
;
import
java.awt.Color
;
import
java.awt.Font
;
import
java.awt.GridLayout
;
import
java.awt.LayoutManager
;
import
javax.swing.JButton
;
import
javax.swing.JFrame
;
import
javax.swing.JLabel
;
public
class
Okno3f_Grid
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Początek main"
);
JFrame
okno
=
new
JFrame
(
"Nasza apka"
);
okno
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
okno
.
setSize
(
600
,
400
);
LayoutManager
layout
=
new
GridLayout
(
2
,
2
);
okno
.
setLayout
(
layout
);
JLabel
label1
=
new
JLabel
(
"Ala ma kota"
);
label1
.
setHorizontalAlignment
(
JLabel
.
CENTER
);
label1
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
30
));
label1
.
setForeground
(
Color
.
RED
);
okno
.
add
(
label1
);
JLabel
label2
=
new
JLabel
(
"Ola ma psa"
);
label2
.
setHorizontalAlignment
(
JLabel
.
RIGHT
);
label2
.
setFont
(
new
Font
(
"Arial"
,
Font
.
ITALIC
,
30
));
label2
.
setForeground
(
Color
.
BLUE
);
okno
.
add
(
label2
);
JButton
button1
=
new
JButton
(
"Kliknij mnie"
);
button1
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
|
Font
.
ITALIC
,
30
));
button1
.
setForeground
(
Color
.
GREEN
);
okno
.
add
(
button1
);
JButton
button2
=
new
JButton
(
"Guzik 2"
);
button2
.
setFont
(
new
Font
(
"Arial"
,
Font
.
BOLD
,
30
));
button2
.
setForeground
(
Color
.
MAGENTA
);
okno
.
add
(
button2
);
okno
.
setVisible
(
true
);
System
.
out
.
println
(
"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