/*
import java.awt.*;
import javax.swing.*;
class Main extends JFrame{
public Main() {
setTitle("계산기 프레임");
Container c = getContentPane();
c.setLayout(new BorderLayout());
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
c.add(p1, BorderLayout.NORTH);
c.add(p2, BorderLayout.CENTER);
c.add(p3, BorderLayout.SOUTH);
p1.setBackground(Color.GRAY);
p1.setLayout(new FlowLayout());
p2.setBackground(Color.WHITE);
p2.setLayout(new GridLayout(4,4,1,1));
p3.setBackground(Color.YELLOW);
p3.setLayout(new FlowLayout());
p1.add(new JLabel("수식입력"));
p1.add(new JTextField(13));
p3.add(new JLabel("계산 결과"));
p3.add(new JTextField(11));
String[] arr = {"CE","계산","+","-","x","/"};
for(int i=0;i<=9;i++) {
p2.add(new JButton(Integer.toString(i)));
}
for(int i=0;i<=5;i++){
JButton b = new JButton(arr[i]);
p2.add(b);
if(i>=2) {
b.setBackground(Color.CYAN);
}
}
setSize(400,300);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
import java.awt.*;
import javax.swing.*;
class Main extends JFrame{
public Main() {
setTitle("여러 개의 패널을 가진 프레임");
Container c = getContentPane();
c.setLayout(new BorderLayout());
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
c.add(p1, BorderLayout.NORTH);
c.add(p2, BorderLayout.CENTER);
c.add(p3, BorderLayout.SOUTH);
p1.setBackground(Color.GRAY);
p1.setLayout(new FlowLayout());
p2.setBackground(Color.WHITE);
p3.setBackground(Color.YELLOW);
p3.setLayout(new FlowLayout());
p1.add(new JButton("열기"));
p1.add(new JButton("닫기"));
p1.add(new JButton("나가기"));
p3.add(new JButton("Word Input"));
p3.add(new JTextField(11));
setSize(500,300);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}