-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextArea1.java
34 lines (29 loc) · 965 Bytes
/
TextArea1.java
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
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("yeah");
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("HARDERRRR!!!!\n");
}
}