COMP2396
Loading...
Searching...
No Matches
TextAreaEx.java
Go to the documentation of this file.
1
import
javax.swing.*;
2
import
java.awt.*;
3
import
java.awt.event.*;
4
5
public
class
TextAreaEx
implements
ActionListener {
6
JTextArea text;
7
8
public
static
void
main
(String[] args) {
9
TextAreaEx
gui =
new
TextAreaEx
();
10
gui.
go
();
11
}
12
13
public
void
go
() {
14
JFrame frame =
new
JFrame();
15
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
16
JPanel panel =
new
JPanel();
17
JButton button =
new
JButton(
"Just Click It"
);
18
button.addActionListener(
this
);
19
text =
new
JTextArea(10, 20);
20
text.setLineWrap(
true
);
21
JScrollPane scroller =
new
JScrollPane(text);
22
scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
23
scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
24
panel.add(scroller);
25
frame.add(panel, BorderLayout.CENTER);
26
frame.add(button, BorderLayout.SOUTH);
27
frame.setSize(350, 300);
28
frame.setVisible(
true
);
29
}
30
31
public
void
actionPerformed
(ActionEvent event) {
32
text.append(
"button clicked\n"
);
33
}
34
}
TextAreaEx
Definition
TextAreaEx.java:5
TextAreaEx.actionPerformed
void actionPerformed(ActionEvent event)
Definition
TextAreaEx.java:31
TextAreaEx.main
static void main(String[] args)
Definition
TextAreaEx.java:8
TextAreaEx.go
void go()
Definition
TextAreaEx.java:13
chapter8
TextAreaEx.java
Generated on Sat Dec 7 2024 17:10:09 for COMP2396 by
1.12.0