-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextArea1.java
More file actions
37 lines (29 loc) · 967 Bytes
/
Copy pathTextArea1.java
File metadata and controls
37 lines (29 loc) · 967 Bytes
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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TextArea1 implements ActionListener{
JTextArea text;
public static void main (String [] args){
TextArea1 gui = new TextArea1();
gui.go();
}
public void go(){
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JButton button = new JButton("Click this ");
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);
frame.getContentPane().add(BorderLayout.CENTER, panel);
frame.getContentPane().add(BorderLayout.SOUTH, button);
frame.setSize(350, 300);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent ev){
text.append("button clicked \n");
}
}