/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Vector<Integer> rain = new Vector<Integer>();
Scanner scan = new Scanner(System.in);
while(true) {
System.out.print("강수량 입력 (0 입력시 종료) >> ");
int n = scan.nextInt();
if(n==0) break;
rain.add(n);
}
}
}
import java.util.*;
class Word {
String english, korean;
public Word() {
}
public Word(String e, String k) {
this.english = e;
this.korean = k;
}
}
class SystemC {
public boolean s = true;
Random dice = new Random();
Scanner scan = new Scanner(System.in);
Vector<Word> v = new Vector<Word>();
public void Setting() {
v.add(new Word("painting", "그림"));
v.add(new Word("emotion", "감정"));
v.add(new Word("baby", "아기"));
v.add(new Word("error", "오류"));
v.add(new Word("society", "사회"));
v.add(new Word("doll", "인형"));
v.add(new Word("bear", "곰"));
v.add(new Word("look", "보기"));
v.add(new Word("eye", "눈"));
v.add(new Word("deal", "거래"));
v.add(new Word("picture", "사진"));
v.add(new Word("human", "사람"));
v.add(new Word("statue", "조각상"));
v.add(new Word("imagination", "상상력"));
v.add(new Word("creativity", "창의력"));
v.add(new Word("knowledge", "지식"));
v.add(new Word("understanding", "이해력"));
System.out.println("**** 영어 단어 테스트 프로그램 \"명품영어\" 입니다. ****");
while(true) {
System.out.print("단어 테스트:1, 단어 삽입:2. 종료:3>> ");
int cmd = scan.nextInt();
if(cmd == 1) {
System.out.println("현재 " + v.size() + "개의 단어가 들어 있습니다. -1을 입력하면 테스트를 종료합니다.");
s = true;
start();
}
else if(cmd == 2) {
System.out.println("영어 단어에 그만을 입력하면 입력을 종료합니다.");
insert();
}
else if(cmd == 3) {
System.out.print("\"명품영어\"를 종료합니다.");
System.exit(0);
}
}
}
public void start() {
while(s) {
int n = dice.nextInt(v.size());
WordQuiz(dice.nextInt(4), n);
}
System.out.println();
}
public void WordQuiz(int position, int k) {
int[][] arr = new int[2][3];
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 3; j++) {
arr[i][j] = -1;
}
}
for(int i = 0; i < 3; i++) {
while(true) {
int n = dice.nextInt(v.size());
if(n != k && n != arr[0][0] && n != arr[0][1] && n != arr[0][2]) {
arr[0][i] = n;
break;
}
}
while(true) {
int n = dice.nextInt(4);
if(n != position && n != arr[1][0] && n != arr[1][1] && n != arr[1][2]) {
arr[1][i] = n;
break;
}
}
}
System.out.println(v.get(k).english + "?");
for(int i = 0; i < 4; i++) {
if(position == i) {
System.out.print("(" + (position+1) + ")" + v.get(k).korean + " ");
}
else {
for(int j = 0; j < 3; j++) {
if(arr[1][j] == i) {
System.out.print("(" + (i+1) + ")" + v.get(arr[0][j]).korean + " ");
}
}
}
}
System.out.print(":>");
int ans = scan.nextInt();
if(ans == -1) {
s = false;
return;
}
else if(position + 1 == ans) {
System.out.println("Excellent !!!");
}
else {
System.out.println("No. !!!");
}
}
public void insert() {
scan.nextLine();
while(true) {
System.out.print("영어 한글 입력 >> ");
String []str = scan.nextLine().split(" ");
if(str[0].equals("그만")) {
System.out.println();
return ;
}
else {
v.add(new Word(str[0], str[1]));
}
}
}
}
public class Main {
public static void main(String[] args) {
SystemC PremiumEnglish = new SystemC();
PremiumEnglish.Setting();
}
}
CUI Command or Console
GUI
awt Button Container ..
swing JButton JLable JTextField ...
container : Frame, Panel ...
component : JButton JLable JTextField
*/
/*
import javax.swing.*;
import java.awt.*;
class Main extends JFrame{
Main(){
setTitle("hello");
setSize(300,500);
setVisible(true);
Container c = getContentPane();
c.setLayout(new FlowLayout());
JButton b1 = new JButton("button1");
b1.setBackground(Color.black);
//b1.setVisible(false);
//b1.setSize(500, 500);
c.add(b1);
c.add(new JButton("button2"));
//c.remove(b1);
//add(new JButton("button"));
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("ContentPane과 JFrame"); // 프레임 타이틀 달기
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 프레임 윈도우를 닫으면
//프로그램을 종료하도록 설정
Container contentPane = getContentPane(); // 컨텐트 팬을 알아낸다.
contentPane.setBackground(Color.orange); // 컨탠트팬의 색으로 오렌지색으로
contentPane.setLayout(new FlowLayout()); // 컨텐트팬에 FlowLayout 배치관
// 리자 달기
contentPane.add(new JButton("OK")); // OK 버튼 달기
contentPane.add(new JButton("Cancel")); // Cancel 버튼 달기
contentPane.add(new JButton("Ignore")); // Ignore 버튼 달기
setSize(300, 150); // 프레임 크기 300x150 설정
setVisible(true); // 화면에 프레임 출력
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("FlowLayout Sample");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
// 컨텐트팬에 FlowLayout 배치관리자 설정
c.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 40));
c.add(new JButton("add"));
c.add(new JButton("sub"));
c.add(new JButton("mul"));
c.add(new JButton("div"));
c.add(new JButton("Calculate"));
setSize(300, 200); // 프레임 크기 300x200 설정
setVisible(true); // 화면에 프레임 출력
}
public static void main(String[] args) {
new Main();
}
}
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("BorderLayout Sample");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
JPanel p1 = new JPanel();
p1.setBackground(Color.orange);
p1.setLayout(new FlowLayout(FlowLayout.LEFT));
p1.add(new JButton("add1"));
p1.add(new JButton("add2"));
c.setLayout(new BorderLayout(30, 20));
c.add(p1, BorderLayout.CENTER);
//c.add(p1, BorderLayout.NORTH);
c.add(new JButton("sub"), BorderLayout.SOUTH);
c.add(new JButton("mul"), BorderLayout.EAST);
c.add(new JButton("div"), BorderLayout.WEST);
setSize(300, 200);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("GridLayout Sample");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout grid = new GridLayout(4, 2, 0, 5);
//grid.setVgap(5);
Container c= getContentPane();
c.setLayout(grid);
c.add(new JLabel(" 이름"));
c.add(new JTextField(""));
c.add(new JLabel(" 학번"));
c.add(new JTextField(""));
c.add(new JLabel(" 학과"));
c.add(new JTextField(""));
c.add(new JLabel(" 과목"));
c.add(new JTextField(""));
setSize(300, 200);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("Null Container Sample");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(null);
JLabel la = new JLabel("Hello, Press Buttons!");
la.setLocation(130,50);
la.setSize(200, 20);
c.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);
c.add(b);
}
setSize(300, 200);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
import java.awt.*;
import javax.swing.*;
public class Main extends JFrame {
public Main() {
setTitle("Random Labels");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(null);
for(int i = 0; i < 20; i++) {
int x = (int)(Math.random()*200) + 50;
int y = (int)(Math.random()*200) + 50;
JLabel label = new JLabel(Integer.toString(i));
label.setLocation(x, y);
label.setSize(10, 10);
label.setOpaque(true);
label.setBackground(Color.blue);
add(label);
}
setSize(300, 300);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}



