-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.java
More file actions
22 lines (20 loc) · 757 Bytes
/
Copy pathForm1.java
File metadata and controls
22 lines (20 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import javax.swing.*;
import java.awt.*;
public class Form1 extends JFrame {
public Form1() {
this.setSize(new Dimension(275, 100));
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Đóng cửa sổ thì chương trình kết thúc
JLabel label1 = new JLabel("Hello World!");
this.add(label1); // add label vào thì mới hiển thị
// this.getContentPane().add(label1); // cách khác để add label
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Form1 form1 = new Form1();
form1.setVisible(true); // show lên màn hình
}
});
}
}