FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programming-Exercises/TextAreal.java at master · RoyTien/Java-Programming-Exercises · GitHub
RoyTien
/
Java-Programming-Exercises
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programming-Exercises
/
TextAreal.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
51 lines (39 loc) · 1.27 KB
Breadcrumbs
Java-Programming-Exercises
/
TextAreal.java
Copy path
File metadata and controls
51 lines (39 loc) · 1.27 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import
javax
.
swing
.*;
import
java
.
awt
.*;
import
java
.
awt
.
event
.*;
public
class
TextAreal
implements
ActionListener
,
ItemListener
{
JTextArea
text
;
JCheckBox
check
;
public
static
void
main
(
String
[]
args
){
TextAreal
gui
=
new
TextAreal
();
gui
.
go
();
}
public
void
go
(){
JFrame
frame
=
new
JFrame
();
JPanel
panel
=
new
JPanel
();
JButton
button
=
new
JButton
(
"Just click it"
);
check
=
new
JCheckBox
(
"Gogogo"
);
panel
.
setLayout
(
new
BoxLayout
(
panel
,
BoxLayout
.
Y_AXIS
));
button
.
addActionListener
(
this
);
text
=
new
JTextArea
(
10
,
20
);
text
.
setLineWrap
(
true
);
JScrollPane
scroller
=
new
JScrollPane
(
text
);
scroller
.
setVerticalScrollBarPolicy
(
ScrollPaneConstants
.
VERTICAL_SCROLLBAR_ALWAYS
);
scroller
.
setHorizontalScrollBarPolicy
(
ScrollPaneConstants
.
HORIZONTAL_SCROLLBAR_NEVER
);
panel
.
add
(
scroller
);
panel
.
add
(
check
);
frame
.
getContentPane
().
add
(
BorderLayout
.
CENTER
,
panel
);
frame
.
getContentPane
().
add
(
BorderLayout
.
SOUTH
,
button
);
frame
.
setSize
(
350
,
300
);
frame
.
setVisible
(
true
);
check
.
addItemListener
(
this
);
}
public
void
actionPerformed
(
ActionEvent
ev
){
text
.
append
(
"Button clicked
\n
"
);
}
public
void
itemStateChanged
(
ItemEvent
ev
){
String
onOrOff
=
"off"
;
if
(
check
.
isSelected
())
onOrOff
=
"on"
;
text
.
append
(
"check box is "
+
onOrOff
+
"
\n
"
);
}
}
Back
|
FazBrowse Home
|
New Git URL