/*
//문제 8
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class Main extends JFrame
{
public Main()
{
setTitle("여러 개의 패널을 가진 프레임");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new BorderLayout(30,20));
JPanel panal = new JPanel();
JButton b = new JButton("열기");
JButton bu = new JButton("닫기");
JButton but = new JButton("나가기");
panal.add(b);
panal.add(bu);
panal.add(but);
panal.setBackground(Color.GRAY);
c.add(panal, BorderLayout.NORTH);
JPanel panal_1 = new JPanel();
Random rand = new Random();
for(int i = 0; i < 10; i++)
{
JLabel label = new JLabel("*");
int x = (int)(rand.nextInt(500));
int y = (int)(rand.nextInt(500));
System.out.println("x = "+x +" y = " +y);
label.setLocation(x,y);
label.setSize(10,10);
label.setOpaque(true);
c.add(label);
}
c.add(panal_1, BorderLayout.CENTER);
JPanel panal_2 = new JPanel();
JButton button = new JButton("Word Input");
JTextField f = new JTextField(" ");
panal_2.add(button);
panal_2.add(f);
panal_2.setBackground(Color.GREEN);
c.add(panal_2, BorderLayout.SOUTH);
setSize(600,600);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
//문제 7
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame
{
public Main()
{
setTitle("계산기 프레임");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new BorderLayout(30,20));
JPanel panel = new JPanel();
JLabel label = new JLabel("수식입력");
JTextField f = new JTextField(" ");
panel.add(label);
panel.add(f);
panel.setBackground(Color.GRAY);
c.add(panel,BorderLayout.NORTH);
JPanel panel_1 = new JPanel();
GridLayout grid = new GridLayout(4,4);
grid.setVgap(5);
panel_1.setLayout(grid);
int [][] a =new int [10][10];
int cnt=0;
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 4; j++)
{
JButton b = new JButton(Integer.toString(i*4+j));
panel_1.add(b);
cnt++;
if(cnt==10) break;
}
}
panel_1.add(new JButton("CE"));
panel_1.add(new JButton("계산"));
JButton bu= new JButton("+");
bu.setBackground(Color.cyan);
panel_1.add(bu);
bu= new JButton("-");
bu.setBackground(Color.cyan);
panel_1.add(bu);
bu = new JButton("x");
bu.setBackground(Color.CYAN);
panel_1.add(bu);
bu = new JButton("/");
bu.setBackground(Color.CYAN);
panel_1.add(bu);
c.add(panel_1,BorderLayout.CENTER);
JPanel panel_2 = new JPanel();
JLabel label_2 = new JLabel("계산결과");
JTextField f_2 = new JTextField(" ");
panel_2.add(label_2);
panel_2.add(f_2);
panel_2.setBackground(Color.GREEN);
c.add(panel_2,BorderLayout.SOUTH);
setSize(600,600);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/