/*import javax.swing.*;
import java.awt.*;
class ContentPane extends JFrame {
public ContentPane() {
setTitle("컨텐트팬");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = getContentPane();
cp.setLayout(null);
JLabel la =new JLabel("Hello, Press Buttons!");
la.setLocation(130, 50);
la.setSize(200,20);
cp.add(la);
for(int i=1;i<=9;i++) {
JButton b = new JButton(Integer.toString(i));
b.setLocation(i*15,i*15);
b.setSize(50,20);
cp.add(b);
}
setSize(300,200);
setVisible(true);
}
}
*
/*
class CP extends JFrame {
CP() {
setTitle("Let's study Java");
Container cp = getContentPane();
setSize(400,200);
setVisible(true);
}
}
*/
import javax.swing.*;
import java.awt.*;
/*
class CP extends JFrame {
public CP() {
setTitle("Border Practice");
Container cp = getContentPane();
cp.setLayout(new BorderLayout(5,7));
cp.add(new JButton("North"), BorderLayout.NORTH);
cp.add(new JButton("South"), BorderLayout.SOUTH);
cp.add(new JButton("East"), BorderLayout.EAST);
cp.add(new JButton("West"), BorderLayout.WEST);
cp.add(new JButton("Center"), BorderLayout.CENTER);
setVisible(true);
setSize(500,250);
}
}
*/
/*
class CP extends JFrame {
public CP() {
setTitle("Ten Color BUttons Frame");
setSize(500,250);
Container cp = getContentPane();
GridLayout grid = new GridLayout(1,10);
cp.setLayout(grid);
for(int i=0;i<10;i++) {
cp.add(new JButton(Integer.toString(i)));
}
setVisible(true);
}
}
*/
/*
class myJButton extends JButton {
public myJButton(String name, Color c) {
super(name);
setBackground(c);
}
}
class CP extends JFrame {
public CP() {
setTitle("Ten Color BUttons Frame");
setSize(500,250);
Container cp = getContentPane();
GridLayout grid = new GridLayout(1,10);
cp.setLayout(grid);
cp.add(new myJButton("0",Color.RED));
cp.add(new myJButton("1",Color.ORANGE));
cp.add(new myJButton("2",Color.YELLOW));
cp.add(new myJButton("3",Color.GREEN));
cp.add(new myJButton("4",Color.CYAN));
cp.add(new myJButton("5",Color.BLUE));
cp.add(new myJButton("6",Color.magenta));
cp.add(new myJButton("7",Color.GRAY));
cp.add(new myJButton("8",Color.PINK));
cp.add(new myJButton("9",Color.lightGray));
setVisible(true);
}
}
*/
/*
class myJLabel extends JLabel {
public myJLabel(String name, Color c) {
super(name);
setBackground(c);
setOpaque(true);
}
}
class CP extends JFrame {
public CP() {
setTitle("4x4 Color Frame");
Container cp = getContentPane();
GridLayout grid = new GridLayout(4,4);
cp.setLayout(grid);
cp.add(new myJLabel("0",Color.RED));
cp.add(new myJLabel("1",Color.ORANGE));
cp.add(new myJLabel("2",Color.YELLOW));
cp.add(new myJLabel("3",Color.GREEN));
cp.add(new myJLabel("4",Color.CYAN));
cp.add(new myJLabel("5",Color.BLUE));
cp.add(new myJLabel("6",Color.magenta));
cp.add(new myJLabel("7",Color.GRAY));
cp.add(new myJLabel("8",Color.PINK));
cp.add(new myJLabel("9",Color.lightGray));
cp.add(new myJLabel("10",Color.WHITE));
cp.add(new myJLabel("11",Color.DARK_GRAY));
cp.add(new myJLabel("12",Color.BLACK));
cp.add(new myJLabel("13",Color.ORANGE));
cp.add(new myJLabel("14",Color.BLUE));
cp.add(new myJLabel("15",Color.magenta));
setSize(400,200);
setVisible(true);
}
}
*/
/*
class CP extends JFrame {
public CP() {
setTitle("Random Labels");
Container cp = getContentPane();
cp.setLayout(null);
for(int i=0;i<20;i++) {
JLabel label = new JLabel(Integer.toString(i));
label.setBackground(Color.BLUE);
int x = (int)(Math.random()*200) + 50;
int y = (int)(Math.random()*200) + 50;
label.setLocation(x,y);
label.setSize(10,10);
cp.add(label);
label.setOpaque(true);
}
setSize(300,300);
setVisible(true);
}
}
*/
/*
class CP extends JFrame {
public CP() {
setTitle("Open Challenge 9");
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
JPanel panel = new JPanel();
panel.setBackground(Color.GRAY);
panel.add(new JButton("Open"));
panel.add(new JButton("Read"));
panel.add(new JButton("Close"));
cp.add(panel,BorderLayout.NORTH);
JPanel p = new JPanel();
p.setBackground(Color.lightGray);
p.setLayout(null);
JLabel label[] = new JLabel[3];
label[0]=new JLabel("Love");
label[1]=new JLabel("Java");
label[2]=new JLabel("Hello");
for(int i=0;i<3;i++) {
int x = (int)(Math.random()*150);
int y = (int)(Math.random()*150);
label[i].setLocation(x,y);
label[i].setSize(100,100);
p.add(label[i]);
}
cp.add(p,BorderLayout.CENTER);
setSize(300,300);
setVisible(true);
}
}
*/
/*
class myJButton extends JButton {
myJButton(String name, Color c) {
super(name);
setBackground(c);
}
}
class CP extends JFrame {
public CP() {
setTitle("계산기 프레임");
setSize(300,300);
setVisible(true);
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
JPanel Upper = new JPanel();
Upper.add(new JLabel("수식입력"));
Upper.add(new JTextField("여기에 입력하세요", 25));
Upper.setBackground(Color.gray);
cp.add(Upper,BorderLayout.NORTH);
JPanel Center = new JPanel();
Center.setLayout(new GridLayout(4,4,5,5));
Center.add(new JButton("0"));
Center.add(new JButton("1"));
Center.add(new JButton("2"));
Center.add(new JButton("3"));
Center.add(new JButton("4"));
Center.add(new JButton("5"));
Center.add(new JButton("6"));
Center.add(new JButton("7"));
Center.add(new JButton("8"));
Center.add(new JButton("9"));
Center.add(new JButton("CE"));
Center.add(new JButton("계산"));
Center.add(new myJButton("+", Color.CYAN));
Center.add(new myJButton("-", Color.CYAN));
Center.add(new myJButton("x", Color.CYAN));
Center.add(new myJButton("/", Color.CYAN));
cp.add(Center,BorderLayout.CENTER);
JPanel Lower = new JPanel();
Lower.add(new JLabel("계산결과"));
Lower.add(new JTextField("이곳에 결과가 나옵니다", 25));
Lower.setBackground(Color.yellow);
cp.add(Lower,BorderLayout.SOUTH);
}
}
*/
import java.awt.event.*;
/*
class CP extends JFrame {
class myActionListener implements ActionListener {
public void MyActionListener() {
}
public void actionPerformed(ActionEvent e) {
JButton b = (JButton)e.getSource();
if(b.getText().equals("Open")) b.setText("열기");
else if(b.getText().equals("열기")) b.setText("Open");
else if(b.getText().equals("Close")) b.setText("닫기");
else if(b.getText().equals("닫기")) b.setText("Close");
else if(b.getText().equals("나가기")) b.setText("Exit");
else if(b.getText().equals("Exit")) b.setText("나가기");
else if(b.getText().equals("Word input")) b.setText("단어 입력");
else b.setText("Word input");
}
}
public CP() {
setTitle("여러개의 패널을 가진 프레임");
setSize(350,350);
setVisible(true);
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
JPanel Upper = new JPanel();
JPanel Center = new JPanel();
Center.setLayout(null);
JPanel Lower = new JPanel();
JButton op = new JButton("열기");
JButton cl = new JButton("닫기");
JButton ex = new JButton("나가기");
Upper.add(op);
Upper.add(cl);
Upper.add(ex);
Upper.setBackground(Color.gray);
cp.add(Upper,BorderLayout.NORTH);
for(int i=0;i<10;i++) {
JLabel la = new JLabel("*");
int x = (int)(Math.random()*200+15);
int y = (int)(Math.random()*200+15);
la.setLocation(x, y);
la.setSize(20,20);
la.setForeground(Color.red);
Center.add(la);
}
cp.add(Center,BorderLayout.CENTER);
JButton wi = new JButton("Word input");
Lower.add(wi);
Lower.add(new JTextField(20));
Lower.setBackground(Color.YELLOW);
cp.add(Lower,BorderLayout.SOUTH);
op.addActionListener(new myActionListener());
cl.addActionListener(new myActionListener());
ex.addActionListener(new myActionListener());
wi.addActionListener(new myActionListener());
}
}
*/
/*
class CP extends JFrame {
private JLabel la = new JLabel("Hello!");
public CP() {
setTitle("Mouse 이벤트 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c =getContentPane();
c.addMouseListener(new MyMouseListener());
c.setLayout(null);
la.setSize(50,50);
la.setLocation(30,30);
c.add(la);
setSize(250,250);
setVisible(true);
}
class MyMouseListener extends MouseAdapter {
@Override
public void mousePressed(MouseEvent e) {
int x = e.getX();
int y = e.getY();
la.setLocation(x,y);
System.out.println(x+","+y);
}
}
}
*/
/*
class CP extends JFrame {
private JLabel[] keyMessage;
public CP() {
setTitle("keyListener 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.addKeyListener(new MyKeyListener());
keyMessage = new JLabel [3];
keyMessage[0] = new JLabel(" getKeyCode() ");
keyMessage[1] = new JLabel(" getKeyChar() ");
keyMessage[2] = new JLabel(" getKeyText() ");
for(int i=0;i<keyMessage.length;i++) {
c.add(keyMessage[i]);
keyMessage[i].setOpaque(true);
keyMessage[i].setBackground(Color.yellow);
}
setSize(300,150);
setVisible(true);
c.setFocusable(true);
c.requestFocus();
}
class MyKeyListener extends KeyAdapter {
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
char keyChar = e.getKeyChar();
keyMessage[0].setText(Integer.toString(keyCode));
keyMessage[1].setText(Character.toString(keyChar));
keyMessage[2].setText(KeyEvent.getKeyText(keyCode));
System.out.println("KeyPressed");
}
public void keyReleased(KeyEvent e ) {
System.out.println("KeyRealsed");
}
public void keyTyped(KeyEvent e) {
System.out.println("KeyTyped");
}
}
}
*/
/*
class CP extends JFrame {
private JLabel la = new JLabel();
public CP() {
setTitle("Key COde 예제 : F1키:초록색, %키:노란색");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.addKeyListener(new MyKeyListener());
c.add(la);
setSize(300,150);
setVisible(true);
c.setFocusable(true);
c.requestFocus();
}
class MyKeyListener extends KeyAdapter {
public void keyPressed(KeyEvent e) {
Container contentPane = (Container)e.getSource();
la.setText(KeyEvent.getKeyText(e.getKeyCode())+"키가 입력되었음");
if(e.getKeyCode()==KeyEvent.VK_) contentPane.setBackground(Color.yellow);
else if(e.getKeyCode()==KeyEvent.VK_F1) contentPane.setBackground(Color.green);
}
}
}
public class Main {
public static void main(String[] args) {
new CP();
}
}*/