-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava224_gui.java
More file actions
63 lines (49 loc) · 1.42 KB
/
Copy pathJava224_gui.java
File metadata and controls
63 lines (49 loc) · 1.42 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
package java0918_gui;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
class ButtonImg extends JFrame {
JButton save, open;
JTextField tf;
public ButtonImg() {
save = new JButton(new ImageIcon("src/java0918_gui/images/save.gif"));
open = new JButton(new ImageIcon("src/java0918_gui/images/open.gif"));
tf = new JTextField(10);
// 말풍선
save.setToolTipText("저장");
open.setToolTipText("열기");
// EmptyBorder(top , left , bottom, right)
save.setBorder(new EmptyBorder(0, 10, 0, 10));
open.setBorder(new EmptyBorder(0, 10, 0, 10));
tf.setBorder(new TitledBorder("기타"));
// Font(글꼴명, 스타일(0 보통, 1굵기, 2 기울기, 3 굵고 기울기), 크기)
Font font = new Font("고딕체", 2, 20);
tf.setFont(font);
// RGB
Color color = new Color(255, 0, 0);
tf.setForeground(color);
tf.setBackground(Color.BLACK);
JPanel p = new JPanel();
p.add(save);
p.add(open);
setLayout(new GridLayout(2, 1));
add(p);
add(tf);
setSize(300, 300);
setLocation(400, 200);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
public class Java224_gui {
public static void main(String[] args) {
new ButtonImg();
}
}