main
package awtSample03;
public class mainClass {
public static void main(String[] args) {
new WindowTest();
}
}
windowTest
public class WindowTest extends Frame implements WindowListener {
public WindowTest() {
super("Layout");
//setLayout(new FlowLayout());// 맨 위에 일렬로 배치
//setLayout(new GridLayout(3,1));//3행 1열
setLayout(null);//사용 안하고 Label위치를 잡아줌
//Label
Label label1 = new Label("label 1");
label1.setBackground(new Color(255, 0, 0));//빨간색
label1.setBounds(150, 30, 50, 30);//위치 1,2,폭,넓이-> 각 객체의 위치설정
add(label1);
//Label
Label label2 = new Label("label 2");
label2.setBackground(Color.yellow);//고정된 색상사용
label2.setBounds(150, 80, 70, 30);//위치 1,2,폭,넓이 //바 위치 포함 0,0
add(label2);
//Button
Button button = new Button();
button.setLabel("Button");
button.setBounds(150, 150, 100, 30);//위치 1,2,폭,넓이
add(button);
setBounds(0, 0, 640, 480);
setVisible(true);
addWindowListener(this);
}
@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' 카테고리의 다른 글
버튼 클릭하여 새로운 창 열기2 (Singleton 사용) (0) | 2020.06.12 |
---|---|
버튼 클릭하여 새로운 창 열기1 (Frame 새로생성) (0) | 2020.06.12 |
체크박스, 라디오버튼 (0) | 2020.06.12 |
가위바위보 게임 프로그램 (0) | 2020.06.12 |
label / 확인창 뜨게하기 (0) | 2020.06.11 |