CUI
Command User Interface
GUI
Graphical User Interface
컨테이너 (종이) = 프레임, 패널
컴포넌트 (스티커) = 라벨, 버튼, ...
컨탠트팬 = 현재 컴포넌트가 붙어있는 컨테이너
import java.awt.*;
import javax.swing.*;
public class Main extends JFrame {
public Main () {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //X누르면 프로그램도 종료
setTitle("300*200 스윙 프레임 만들기"); //제목 정하기
setSize(300,200); //사이즈
setVisible(true); //보이게 하기
Container contentPane = getContentPane(); //컨탠트팬 알아내기
//contentPane.setBackground(Color.ORANGE); //컨텐트팬의 배경색을 오렌지색으로 설정
//contentPane.setLayout(new FlowLayout()); //플로우레이아웃으로 설정
//contentPane.setLayout(new BorderLayout());
contentPane.setLayout(new GridLayout(4,2));
JLabel la1 = new JLabel("라벨1");
JLabel la2 = new JLabel("라벨2");
JLabel la3 = new JLabel("라벨3");
JButton b1 = new JButton("OK");
JButton b2 = new JButton("Cancle");
//JButton b3 = new JButton("Ignore");
JTextField f1 = new JTextField();
contentPane.add(la1);
contentPane.add(b1);
contentPane.add(la2);
contentPane.add(b2);
contentPane.add(la3);
contentPane.add(f1);
}
public static void main(String[] args) {
Main frame = new Main();
}
}*/
/*
import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
public class Main extends JFrame {
public Main () {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Let'study java");
setSize(400,200);
setVisible(true);
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
JButton b1 = new JButton("North");
JButton b2 = new JButton("West");
JButton b3 = new JButton("Center");
JButton b4 = new JButton("East");
JButton b5 = new JButton("South");
cp.add(b1,BorderLayout.NORTH);
cp.add(b2,BorderLayout.WEST);
cp.add(b3,BorderLayout.CENTER);
cp.add(b4,BorderLayout.EAST);
cp.add(b5,BorderLayout.SOUTH);
}
public static void main(String[] args) {
Main frame = new Main();
}
}
import java.awt.*;
import javax.swing.*;
public class Main extends JFrame {
public Main () {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,400);
setVisible(true);
Container cp = getContentPane();
cp.setLayout(new GridLayout(1,10));
JButton b = new JButton("0");
b.setBackground(Color.red);
cp.add(b);
b = new JButton("1");
b.setBackground(Color.orange);
cp.add(b);
b = new JButton("2");
b.setBackground(Color.yellow);
cp.add(b);
b = new JButton("3");
b.setBackground(Color.green);
cp.add(b);
b = new JButton("4");
b.setBackground(Color.cyan);
cp.add(b);
b = new JButton("5");
b.setBackground(Color.blue);
cp.add(b);
b = new JButton("6");
b.setBackground(Color.magenta);
cp.add(b);
b = new JButton("7");
b.setBackground(Color.gray);
cp.add(b);
b = new JButton("8");
b.setBackground(Color.pink);
cp.add(b);
b = new JButton("9");
b.setBackground(Color.lightGray);
cp.add(b);
}
public static void main(String[] args) {
Main frame = new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
public class Main extends JFrame {
public Main () {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,500);
setVisible(true);
Container cp = getContentPane();
cp.setLayout(new GridLayout(4,4));
JButton b = new JButton("0");
b.setBackground(Color.red);
cp.add(b);
b = new JButton("1");
b.setBackground(Color.orange);
cp.add(b);
b = new JButton("2");
b.setBackground(Color.yellow);
cp.add(b);
b = new JButton("3");
b.setBackground(Color.green);
cp.add(b);
b = new JButton("4");
b.setBackground(Color.cyan);
cp.add(b);
b = new JButton("5");
b.setBackground(Color.blue);
cp.add(b);
b = new JButton("6");
b.setBackground(Color.magenta);
cp.add(b);
b = new JButton("7");
b.setBackground(Color.gray);
cp.add(b);
b = new JButton("8");
b.setBackground(Color.pink);
cp.add(b);
b = new JButton("9");
b.setBackground(Color.lightGray);
cp.add(b);
*/
import java.awt.*;
import javax.swing.*;
public class Main extends JFrame {
public Main () {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(10000,10000);
setVisible(true);
Container cp = getContentPane();
cp.setLayout(new GridLayout(4,4));
JButton b = new JButton("0");
b.setBackground(Color.red);
cp.add(b);
b = new JButton("1");
b.setBackground(Color.orange);
cp.add(b);
b = new JButton("2");
b.setBackground(Color.yellow);
cp.add(b);
b = new JButton("3");
b.setBackground(Color.green);
cp.add(b);
b = new JButton("4");
b.setBackground(Color.cyan);
cp.add(b);
b = new JButton("5");
b.setBackground(Color.blue);
cp.add(b);
b = new JButton("6");
b.setBackground(Color.magenta);
cp.add(b);
b = new JButton("7");
b.setBackground(Color.gray);
cp.add(b);
b = new JButton("8");
b.setBackground(Color.pink);
cp.add(b);
b = new JButton("9");
b.setBackground(Color.lightGray);
cp.add(b);
b = new JButton("10");
b.setBackground(Color.white);
cp.add(b);
b = new JButton("11");
b.setBackground(Color.darkGray);
cp.add(b);
b = new JButton("12");
b.setBackground(Color.black);
cp.add(b);
b = new JButton("13");
b.setBackground(Color.orange);
cp.add(b);
b = new JButton("14");
b.setBackground(Color.blue);
cp.add(b);
b = new JButton("15");
b.setBackground(Color.magenta);
cp.add(b);
}
public static void main(String[] args) {
Main frame = new Main();
}
}



