본문 바로가기

JAVA/UI

label / 확인창 뜨게하기

예시

 

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

	public WindowTest() {
		super("Label");//=setTitle()
		
		//setSize(640, 480);
		//setLocation(0, 0);
		setBounds(0, 0, 640, 480);//위의 두개와 동일
		
		setVisible(true);
		
		addWindowListener(this);

		Label label = new Label();
		label.setText("Label");
		add(label);
		
		Label label1 = new Label("label 입니다");//한글깨짐 수정함.
		add(label1);
		Label label2 = new Label("점심시간 5분전 입니다");//한글깨짐 수정함.
		add(label2);
		
		System.out.println("WindowTest WindowTest()");
		
		// MessageBox
		JOptionPane.showMessageDialog(null, "확인창 만들기");
		
	}
	@Override
	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub
	}
	@Override
	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub
	}
	@Override
	public void windowClosing(WindowEvent e) {
		// TODO Auto-generated method stub
		System.exit(0);
	}
	@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
	}
}

'JAVA > UI' 카테고리의 다른 글

체크박스, 라디오버튼  (0) 2020.06.12
가위바위보 게임 프로그램  (0) 2020.06.12
Observer  (0) 2020.06.11
Label 과 Panel  (0) 2020.06.11
AWT  (0) 2020.06.11