[JAVA 개발] 패널(Panel) 확인, 취소 소스_2
import javax.swing.*;
import java.awt.*;
class Exam3 extends JFrame {
private Button bt = new Button("Test");
private Button bt1 = new Button("Test1");
private GridLayout gl =new GridLayout(1,2); //1행 2열
public Exam3(String title){
super(title);
this.init();
/*
* 위치 설정
*/
super.setSize(300,200);
super.setLocation(400, 500);
super.setResizable(false);
super.setVisible(true);
}
/*
* 레이아웃 설정
*/
public void init(){
this.setLayout(gl); //프레임 레이아웃
bt.setBackground(Color.yellow);
bt1.setBackground(Color.magenta);
GridLayout gl = new GridLayout(1,2,5,5);
Panel p =new Panel(); //패널 선언
p.setLayout(gl); //패널 레이아웃
//통합하여 Panel p = new Panel(gl); 라고 하여도 됨
p.add(bt);
p.add(bt1);
this.add("South",p);
}
}
public class Exam3Test {
public static void main(String[] args) {
Exam2 ex = new Exam2("확인버튼 만들기");
}
}