오늘은 자바 GUI에 대해 알아보자
javax.swing 패키지 내에 있다.AWT객체와는 달리, 모든 플랫폼에 대해 uniform한 GUI를 제공하기 때문에 현재 많이 사용되고 있다.
Swing클래스의 상속 관계.
최상위 클래스 Object로부터indirect 상속 관계를 가진다.

기본적인
SwingGUI의 구성요소

Container은 Component를 상속하고 있기 때문에, Container안에 또다른 Container를 넣는 것도 가능하다.
-> 다양한 GUI표현 가능.
JComponent클래스 (package javax.swing)는 Container클래스의 subclass이다.
JComponent는 모든 lightweight한 Swing Component들의 superclass이다.
Swing GUI 구성요소들을 포함하는 대부분의 Window들은 JFrame의 인스턴스이거나 그 subclass를 포함한다.JFrame은 Window의 기본적인 속성을 제공한다import javax.swing.*;
import java.awt.*;
public class LabelFrame extends JFrame{
private final JLabel label1;
private final JLabel label2;
private final JLabel label3;
public LabelFrame(){
super("Testing JLabel");
setLayout(new FlowLayout());
label1 = new JLabel("Label with test");
label1.setToolTipText("This is label1");
add(label1);
Icon bug = new ImageIcon(getClass().getResource("bug1.gif"));
label2 = new JLabel("Label with test and icon", bug, SwingConstants.LEFT);
label2.setToolTipText("This is label2");
add(label2);
label3 = new JLabel();
label3.setText("Label with ocon and text at bottom");
label3.setIcon(bug);
label3.setHorizontalTextPosition(SwingConstants.CENTER);
label3.setVerticalTextPosition(SwingConstants.BOTTOM);
label3.setToolTipText("this is label3");
add(label3);
}
}
package Final_Test_Training;
import javax.swing.*;
public class LabelTest {
public static void main(String[] args) {
LabelFrame labelFrame = new LabelFrame();
labelFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
labelFrame.setSize(260, 180);
labelFrame.setVisible(true);
}
}

좋은 글 감사합니다