-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.java
More file actions
58 lines (53 loc) · 1.22 KB
/
test2.java
File metadata and controls
58 lines (53 loc) · 1.22 KB
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
52
53
54
55
56
57
58
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.Border;
public class test2 {
JFrame frame=new JFrame("test2");
JTextArea text;
JButton button1;
JButton button2;
int count;
public static void main(String[] args)
{
test2 t=new test2();
t.go();
}
public void go()
{
text=new JTextArea(8,20);
text.setEditable(false);
JScrollPane jsp=new JScrollPane(text,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
button1=new JButton("button1");
button1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
button2=new JButton("button2");
button2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
count++;
String str=String.valueOf(count);
text.setText(str);
}
});
JPanel panel=new JPanel();
panel.add(jsp);
panel.add(button1);
panel.add(button2);
Border etched=BorderFactory.createEtchedBorder();
panel.setBorder(etched);
Container con=frame.getContentPane();
con.add(panel,"Center");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}