728x90
반응형
package gui;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
public class S04_JLabel extends JFrame {
// JLabel : 텍스트를 표시하기 위한 컴포넌트
public S04_JLabel() {
JLabel label1 = new JLabel("This is a JLabel Component");
label1.setBounds(0, 0, 500, 50);
label1.setForeground(Color.blue);
label1.setFont(new Font("Consolas", Font.BOLD, 15));
JLabel label2 = new JLabel("This is a JLabel Component");
label2.setBounds(0, 50, 485, 50);
label2.setForeground(Color.red);
label2.setFont(new Font("Consolas", Font.BOLD, 15));
label2.setHorizontalAlignment(SwingConstants.RIGHT);
add(label1);
add(label2);
setLayout(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(500, 500);
setLocation(100, 100);
setVisible(true);
}
public static void main(String[] args) {
new S04_JLabel();
}
}
728x90
반응형
'JAVA > Swing' 카테고리의 다른 글
[JAVA] JTextArea (0) | 2023.05.02 |
---|---|
[JAVA] JTextField (0) | 2023.04.27 |
[JAVA] JButton (0) | 2023.04.27 |
[JAVA] Border Layout (0) | 2023.04.27 |
[JAVA] Swing (0) | 2023.04.27 |