-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextCalc.java
More file actions
79 lines (77 loc) · 2.51 KB
/
Copy pathtextCalc.java
File metadata and controls
79 lines (77 loc) · 2.51 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
class Calculator extends JFrame {
public Calculator(String title) {
// this없어도됨
setTitle(title);
// size설정(width,height)
setSize(230, 400);
setLocation(800, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel jp1 = new JPanel();
JPanel jp2 = new JPanel();
JPanel
jp3 = new JPanel();
this.add(jp1);
jp1.setLayout(new FlowLayout());
jp2.setLayout(new GridLayout(4, 4));
jp2.setPreferredSize(new Dimension(220, 220));
JButton b1 = new JButton("1");
jp2.add(b1);
JButton b2 = new JButton("2");
jp2.add(b2);
JButton b3 = new JButton("3");
jp2.add(b3);
JButton bminer = new JButton("-");
jp2.add(bminer);
JButton b4 = new JButton("4");
jp2.add(b4);
JButton b5 = new JButton("5");
jp2.add(b5);
JButton b6 = new JButton("6");
jp2.add(b6);
JButton bplus = new JButton("+");
jp2.add(bplus);
JButton b7 = new JButton("7");
jp2.add(b7);
JButton b8 = new JButton("8");
jp2.add(b8);
JButton b9 = new JButton("9");
jp2.add(b9);
JButton bgob = new JButton("*");
jp2.add(bgob);
JButton b0 = new JButton("0");
jp2.add(b0);
JButton bdot = new JButton(".");
jp2.add(bdot);
JButton beq = new JButton("=");
jp2.add(beq);
JButton bna = new JButton("/");
jp2.add(bna);
jp3.setLayout(new FlowLayout(FlowLayout.RIGHT));
jp3.setPreferredSize(new Dimension(220, 100));
JLabel text1 = new JLabel("만든이 : ㅁㄴㅇ");
JLabel text2 = new JLabel("eMail : ㅁㄴㅇ@naver.com");
jp3.add(text1);
jp3.add(text2);
JButton Clear = new JButton("Clear");
Clear.setPreferredSize(new Dimension(220, 30));
JLabel idlbl = new JLabel("Swing으로 구현한 계산기");
jp1.add(idlbl);
JTextField idtf = new JTextField(24);
jp1.add(idtf);
jp1.add(jp2);
jp1.add(Clear);
jp1.add(jp3);
this.setVisible(true);
}
public static void main(String[] args) { //인수로 넣음 new Calculator("계산기"); }
new Calculator("계산기");
}
}