본문 바로가기

Java/java 기초

awt - label

package awtSamplee02;

import java.awt.Label;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class WindowTest extends JFrame implements WindowListener {

	public WindowTest() {
		super("lable");	
		setTitle("레이블");
		
		setBounds(0, 0, 640, 480);
		
		setVisible(true);
		
		addWindowListener(this);
		
		Label label = new Label();
//		-Dfile.encoding=MS949 를 Propertise - > Debug Setting - > Edit -> argument 하단 에 지정해줘야 글씨가 깨지지 않는다.
		label.setText("여기가 레이블입니다");
		add(label);
		
		Label label1 = new Label("추가 레이블입니다.");
		add(label1);
		
		System.out.println("WindowTest WindowTest()");
		
		//나오는순간 프로그램이 멈춘다. 실시간 디버깅 불가
		//확인해 보는 작업으로 주로 사용한다.
		JOptionPane.showMessageDialog(null, "WindowTest WindowTest() 실행");
		
		
	}

	@Override
	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub
		System.exit(0);

	}

	@Override
	public void windowClosing(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowDeactivated(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowDeiconified(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowIconified(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowOpened(WindowEvent e) {
		// TODO Auto-generated method stub

	}

}

 

package awtSamplee02;

public class mainClass {
	public static void main(String[] args) {
		new WindowTest();
	}
}