package awtSample03;
import java.awt.Button;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class WindowTest extends Frame implements WindowListener {
public WindowTest() {
super("layout");
// setLayout(new FlowLayout());
// 화면 해상도에 따라 달라진다.
// setLayout(new GridLayout(3, 1));
setLayout(null);
// label1
Label label1 = new Label("레이블1입니다.");
label1.setBackground(new Color(255, 0, 0));
label1.setSize(150, 30);
label1.setLocation(100, 100);
add(label1);
// label2
Label label2 = new Label("레이블2입니다.");
label2.setBackground(new Color(0, 255, 0));
label2.setBounds(100, 200, 200, 100);
add(label2);
Button button = new Button();
button.setLabel("버튼");
button.setBounds(100, 350, 200, 100);
add(button);
setBounds(0, 0, 640, 480);
setVisible(true);
addWindowListener(this);
}
@Override
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent arg0) {
// TODO Auto-generated method stub
System.exit(0);
}
@Override
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
}
package awtSample03;
public class mainClass {
public static void main(String[] args) {
new WindowTest();
}
}
'Java > java 기초' 카테고리의 다른 글
awt- 버튼 클릭 이벤트 (0) | 2019.12.05 |
---|---|
awt - Panel (0) | 2019.12.05 |
이클립스 (eclipse) 기준으로 awt의 글씨가 깨질때 (0) | 2019.12.05 |
awt - label (0) | 2019.12.05 |
awt 기초 부분 공부하기 (0) | 2019.12.05 |