Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
Enigma
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Flori N
Enigma
Commits
c153a494
Commit
c153a494
authored
Dec 04, 2019
by
Uli Bähr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
neue Klasse ChkBoxPanel
parent
dcfe6fe1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
src/main/java/projekt/enigma/view/ChkBoxPanel.java
src/main/java/projekt/enigma/view/ChkBoxPanel.java
+74
-0
No files found.
src/main/java/projekt/enigma/view/ChkBoxPanel.java
0 → 100644
View file @
c153a494
package
projekt.enigma.view
;
import
java.awt.*
;
import
javax.swing.*
;
public
class
ChkBoxPanel
extends
JPanel
{
/*private static JPanel panel = new JPanel();*/
private
static
JCheckBox
[]
checkbox
;
private
static
Character
[]
alphabet
;
/* = {'A','B','C','D'};*/
private
static
int
charSize
;
public
ChkBoxPanel
(
Character
[]
alphabet
)
{
this
.
charSize
=
alphabet
.
length
;
this
.
alphabet
=
alphabet
;
/*this.setTitle("Vertausche Buchstaben");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);*/
this
.
setSize
(
30
,
charSize
*
25
);
//this.setLocation(getMousePosition()/*.x, getMousePosition().y+this.getHeight()+30*/);
initializeComponents
();
}
private
void
initializeComponents
()
{
this
.
checkbox
=
new
JCheckBox
[
charSize
];
GridLayout
panelLayout
=
new
GridLayout
();
this
.
setLayout
(
panelLayout
);
if
(!(
charSize
%
2
==
0
))
{
this
.
setSize
(
30
,
(
charSize
+
1
)
*
20
);
panelLayout
.
setRows
((
charSize
+
1
)
/
2
);
}
else
{
this
.
setSize
(
30
,
charSize
*
10
);
panelLayout
.
setRows
(
charSize
/
2
);
}
panelLayout
.
setColumns
(
2
);
//panelLayout.setVgap(5);
//panelLayout.setHgap(-5);
for
(
int
i
=
0
;
i
<
charSize
;
i
++)
{
checkbox
[
i
]
=
new
JCheckBox
(
alphabet
[
i
]
+
""
);
checkbox
[
i
].
setSize
(
15
,
20
);
checkbox
[
i
].
setHorizontalTextPosition
(
SwingConstants
.
CENTER
);
checkbox
[
i
].
setVerticalTextPosition
(
SwingConstants
.
TOP
);
/* if (!(i%2==0)){
}*/
checkbox
[
i
].
setMargin
(
new
Insets
(
0
,
20
,
0
,
20
));
//checkbox[i].setLocation(20, (i + 1) * 30);
this
.
add
(
checkbox
[
i
]);
}
/* this.getContentPane().add(panel);*/
checkbox
[
0
].
setSelected
(
true
);
//this.add(panel);
//this.setLocation(100, 100);
this
.
setVisible
(
true
);
}
private
int
isChecked
()
{
for
(
int
i
=
0
;
i
<
charSize
;
i
++)
{
if
(
checkbox
[
i
].
isSelected
())
{
// do something...
}
else
{
// do something else...
}
}
return
0
;
}
}
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