/*
import java.util.Scanner;
class Circle {
static int num;
private double x, y;
private int radius;
public Circle(double x, double y, int radius) {
this.x = x;
this.y = y;
this.radius = radius;
}
public void show() {
System.out.println("("+x+", "+y+")"+radius);
}
}
class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Circle c[] = new Circle[3];
// for (int i = 0; i < c.length; i++) {
// System.out.print("x, y, radius >>");
// double x = scanner.nextDouble();
// double y = scanner.nextDouble();
// int radius = scanner.nextInt();
// c[i] = new Circle(x, y, radius);
// }
// for(int i=0; i<c.length; i++)
// c[i].show();
//
Circle c = new Circle(1,1,2);
c.num=0;
Circle d = new Circle(2,2,3);
d.num++;
//System.out.println(d.num);
System.out.println(Circle.num);
scanner.close();
}
}
*/
/*
import java.util.Scanner;
class Phone{
int num;
String name;
String tel;
public Phone(String name,String tel) {
this.name=name;
this.tel=tel;
}
public void show() {
System.out.println();
}
}
class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//1.
System.out.print("인원수>>");
int n = sc.nextInt();
Phone p[] = new Phone[n];
//2. scan 받아서 객체 생성
for(int i=0;i<n;i++) {
System.out.print("이름과 전화번호(이름과 번호는 빈 칸없이 입력)>>");
String name = sc.next();
String tel = sc.next();
p[i] = new Phone(name,tel);
}
System.out.println("저장되었습니다...");
//3. 검색
while(true) {
System.out.print("검색할 이름>>");
String name = sc.next();
if(name.equals("그만")) {
return ;
}
else {
boolean isFind = false;
for(int i=0;i<n;i++) {
if(p[i].name.equals(name)) {
System.out.println(p[i].name+"의 번호는 "+p[i].tel+" 입니다.");
isFind = true;
break;
}
}
if(isFind==false) System.out.println(name+" 이 없습니다.");
}
}
}
}
*/
/*
-랜덤으로 1에서 100 까지의 숫자를 고른 뒤 플레이어가 그 숫자를 맞추게 함
-자신이 예상한 숫자를 textfield에다가 입력
-10번 안에 맞추어야 하고 그러지 못하면 게임에서 진다
-게임이 끝나면 다시 메인 화면으로 돌아간다.
*/
/*
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Main extends JFrame{
ImageIcon updown= new ImageIcon("arrows.png");
ImageIcon up= new ImageIcon("up-arrow.png");
ImageIcon down= new ImageIcon("down-arrow.png");
JLabel MainImage= new JLabel(updown);
JButton startB = new JButton("Game Start",updown);
JLabel MainL= new JLabel("UP AND DOWN GAME");
JTextField gameT= new JTextField(10);
JLabel gameL= new JLabel("1~100 숫자를 입력하시오:");
JLabel gameUD= new JLabel();
Container c= getContentPane();
String a;
int t, c1=0;
JLabel cL= new JLabel("남은 횟수: 15");
int flag=2;
JButton finish = new JButton("메인 화면으로 돌아가기");
JLabel wl= new JLabel();
int com;
public Main() {
setTitle("Up and Down Game");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
c.setLayout(null);
c.setBackground(Color.YELLOW);
startB.setSize(200,200);
startB.setLocation(200,200);
startB.addActionListener(new myActionListener());
c.add(startB);
Font font= new Font("UP AND DOWN GAME",Font.BOLD,40);
MainL.setFont(font);
MainL.setSize(500, 100);
MainL.setLocation(90,100);
c.add(MainL);
gameT.setLocation(246,40);
gameT.setSize(200,30);
gameT.setVisible(false);
gameT.addActionListener(new myActionListener1());
c.add(gameT);
Font font1= new Font("UP AND DOWN GAME",Font.BOLD,13);
gameL.setFont(font1);
gameL.setLocation(90,5);
gameL.setSize(500,100);
gameL.setVisible(false);
c.add(gameL);
Font font2= new Font("UP AND DOWN GAME",Font.BOLD,13);
cL.setFont(font2);
cL.setLocation(500,-35);
cL.setSize(500,100);
cL.setVisible(false);
c.add(cL);
Font font3= new Font("UP AND DOWN GAME",Font.BOLD,60);
gameUD.setFont(font3);
gameUD.setLocation(220,250);
gameUD.setSize(500,100);
c.add(gameUD);
Font font4= new Font("UP AND DOWN GAME",Font.BOLD,30);
wl.setFont(font4);
wl.setLocation(60,230);;
wl.setSize(500,100);;
c.add(wl);
wl.setVisible(false);
finish.setLocation(350,480);
finish.setSize(200,70);
c.add(finish);
finish.setVisible(false);
finish.addActionListener(new myActionListener2());
setSize(600,600);
setVisible(true);
}
class myActionListener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
com=(int)(Math.random()*100);
startB.setVisible(false);
MainL.setVisible(false);
gameT.setVisible(true);
gameL.setVisible(true);
cL.setVisible(true);
System.out.println(com);
}
}
class myActionListener1 implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
a=e.getActionCommand();
t=Integer.parseInt(a);
c1++;
run();
}
}
class myActionListener2 implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
StartScreen();
}
}
public void StartScreen() {
finish.setVisible(false);
wl.setVisible(false);
wl.setText("");
c1=0;
startB.setVisible(true);
gameT.setText("");
MainL.setVisible(true);
}
public void run() {
cL.setText("남은 횟수: "+Integer.toString(15-c1));
if(t>com) {
gameUD.setText("DOWN");
gameUD.setForeground(new Color((int)(Math.random()*255),(int)(Math.random()*255),(int)(Math.random()*255)));
}
if(t<com)
{
gameUD.setText("UP");
gameUD.setForeground(new Color((int)(Math.random()*255),(int)(Math.random()*255),(int)(Math.random()*255)));
}
if(t==com&&c1<11) {
flag=1;
result();
}
if(c1>14) {
flag=0;
result();
}
}
public void result() {
gameT.setVisible(false);
gameL.setVisible(false);
cL.setVisible(false);
gameUD.setText("");
wl.setVisible(true);
finish.setVisible(true);
if(flag==1) {
wl.setText("축하합니다 "+Integer.toString(c1)+"번 만에 맞추셨습니다");
}
if(flag==0) {
wl.setText("숫자는 "+Integer.toString(com)+" 였습니다");
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
class TimerThread extends Thread {
private JLabel timerLabel;
public TimerThread(JLabel timerLabel) {
this.timerLabel = timerLabel;
}
public void run() {
int n=0;;
while(true) {
timerLabel.setText(Integer.toString(n));
n++;
try {
Thread.sleep(1000);
}
catch(InterruptedException e) {
return;
}
}
}
}
public class Main extends JFrame{
public Main() {
setTitle("Thread를 상속받은 타이머 스레드 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c= getContentPane();
c.setLayout(new FlowLayout());
JLabel timerLabel= new JLabel();
timerLabel.setFont(new Font("Gothic",Font.ITALIC,80));
c.add(timerLabel);
TimerThread th = new TimerThread(timerLabel);
setSize(300,170);
setVisible(true);
th.start();
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
class TimerRunnable implements Runnable{
private JLabel timerLabel;
public TimerRunnable(JLabel timerLabel) {
this.timerLabel = timerLabel;
}
public void run() {
int n=0;
while(true) {
timerLabel.setText(Integer.toString(n));
n++;
try {
Thread.sleep(1000);
}
catch(InterruptedException e) {
return;
}
}
}
}
public class Main extends JFrame{
public Main() {
setTitle("Runnable을 구현한 타이머 스레드 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
JLabel timerLabel= new JLabel();
timerLabel.setFont(new Font("Gothic", Font.ITALIC,80));
c.add(timerLabel);
TimerRunnable runnable = new TimerRunnable(timerLabel);
Thread th = new Thread(runnable);
setSize(250,150);
setVisible(true);
th.start();
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
class FlickeringLabel extends JLabel implements Runnable{
private long delay;
public FlickeringLabel(String text, long delay) {
super(text);
this.delay= delay;
setOpaque(true);
Thread th= new Thread(this);
th.start();
}
public void run() {
int n=0;
while(true) {
if(n==0) setBackground(Color.YELLOW);
else setBackground(Color.GREEN);
if(n==0) n=1;
else n=0;
try {
Thread.sleep(delay);
}
catch(InterruptedException e) {
return;
}
}
}
}
public class Main extends JFrame{
public Main() {
setTitle("FlickeringLabelEx 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
FlickeringLabel fLabel = new FlickeringLabel("깜박",500);
JLabel label = new JLabel("안깜박");
FlickeringLabel fLabel2 = new FlickeringLabel("깜박",300);
c.add(fLabel);
c.add(label);
c.add(fLabel2);
setSize(300,150);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class TimerRunnable implements Runnable {
private JLabel timerLabel;
public TimerRunnable(JLabel timerLabel) {
this.timerLabel = timerLabel;
}
public void run() {
int n=0;
while(true) {
timerLabel.setText(Integer.toString(n));
n++;
try {
Thread.sleep(1000);
}
catch(InterruptedException e) {
return;
}
}
}
}
public class Main extends JFrame{
private Thread th;
public Main() {
setTitle("ThreadInterruptEx 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
JLabel timerLabel = new JLabel();
timerLabel.setFont(new Font("Gothic",Font.ITALIC,80));
TimerRunnable runnable = new TimerRunnable(timerLabel);
th=new Thread(runnable);
c.add(timerLabel);
JButton btn = new JButton("kill Timer");
btn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
th.interrupt();
JButton btn = (JButton)e.getSource();
btn.setEnabled(false);
}
});
c.add(btn);
setSize(300,170);
setVisible(true);
th.start();
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class RandomThread extends Thread{
private Container contentPane;
private boolean flag=false;
public RandomThread(Container contentPane) {
this.contentPane = contentPane;
}
public void finish() {
flag = true;
}
public void run() {
while(true) {
int x = ((int)(Math.random()*contentPane.getWidth()));
int y = ((int)(Math.random()*contentPane.getHeight()));
JLabel label = new JLabel("java");
label.setSize(80,30);
label.setLocation(x,y);
contentPane.add(label);
contentPane.repaint();
try {
Thread.sleep(300);
if(flag==true) {
contentPane.removeAll();
label = new JLabel("finish");
label.setSize(80,30);
label.setLocation(100,100);
label.setForeground(Color.RED);
contentPane.add(label);
contentPane.repaint();
return;
}
}
catch(InterruptedException e) {return;}
}
}
}
public class Main extends JFrame{
private RandomThread th;
public Main() {
setTitle("ThreadFinsihFlagEx 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(null);
c.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
th.finish();
}
});
setSize(300,200);
setVisible(true);
th = new RandomThread(c);
th.start();
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import java.awt.event.*;
import java.util.Calendar;
import javax.swing.*;
class clock extends Thread{
JLabel clockL= new JLabel();
public void run() {
String clockText;
int hour,min,second;
while(true) {
Calendar c= Calendar.getInstance();
hour = c.get(Calendar.HOUR_OF_DAY);
min = c.get(Calendar.MINUTE);
second = c.get(Calendar.SECOND);
clockText = Integer.toString(hour-12);
clockText = clockText.concat("시 ");
clockText = clockText.concat(Integer.toString(min));
clockText = clockText.concat("분 ");
clockText = clockText.concat(Integer.toString(second));
clockText = clockText.concat("초 ");
clockL.setText(clockText);
try {
Thread.sleep(1000);
}
catch(InterruptedException e) {
return;
}
}
}
}
public class Main extends JFrame{
public Main(){
setTitle("Digital clock");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c= getContentPane();
c.setLayout(new FlowLayout());
clock cl = new clock();
c.add(cl.clockL);
setSize(300,300);
setVisible(true);
cl.start();
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Main extends JFrame{
MyPanel panel = new MyPanel();
public Main(){
setTitle("Random Circle");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setContentPane(panel);
setSize(500,500);
setVisible(true);
}
class MyPanel extends JPanel implements Runnable{
int x=0,y=0;
public MyPanel() {
addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
run();
}
});
}
public void run() {
while(true) {
x=(int)(Math.random()*300);
y=(int)(Math.random()*300);
try {
Thread.sleep(400);
}catch(InterruptedException e) {
return;
}
repaint();
}
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawOval(x, y, 50, 50);
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Main extends JFrame{
private JCheckBox [] buttons = new JCheckBox [2];
private String [] names = {"버튼 비활성화","버튼 감추기"};
JButton b = new JButton("test button");
public Main(){
setTitle("CheckBox Practice");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
MyItemListener listener = new MyItemListener();
for(int i=0; i<buttons.length; i++)
{
buttons[i] = new JCheckBox(names[i]);
c.add(buttons[i]);
buttons[i].addItemListener(listener);
}
c.add(b);
setSize(300,200);
setVisible(true);
}
class MyItemListener implements ItemListener {
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange() == ItemEvent.SELECTED) {
if(e.getItem() == buttons[0])
{
b.setEnabled(false);
}
else if(e.getItem() == buttons[1])
{
b.setVisible(false);
}
}
else
{
b.setEnabled(true);
b.setVisible(true);
}
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Main extends JFrame{
public Main(){
JButton b = new JButton("계산");
setTitle("Money Changer");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.setBackground(Color.PINK);
JTextField mtf = new JTextField(20);
c.add(new JLabel("금액 "));
c.add(mtf);
c.add(b);
JLabel[] la = new JLabel[8];
String[] lastr = {"오만원 ","만원 ","천원 ","500원 ","100원 ","50원 ","10원 ","1원 "};
JTextField[] tf = new JTextField[8];
for(int i=0;i<la.length;i++) {
la[i] = new JLabel(lastr[i]);
tf[i] = new JTextField(20);
c.add(la[i]);
c.add(tf[i]);
}
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int money = Integer.valueOf(mtf.getText());
//System.out.println(money);
tf[0].setText(Integer.toString(money/50000));
money=money%50000;
tf[1].setText(Integer.toString(money/10000));
money=money%10000;
tf[2].setText(Integer.toString(money/1000));
money=money%1000;
tf[3].setText(Integer.toString(money/500));
money=money%500;
tf[4].setText(Integer.toString(money/100));
money=money%100;
tf[5].setText(Integer.toString(money/50));
money=money%50;
tf[6].setText(Integer.toString(money/10));
money=money%10;
tf[7].setText(Integer.toString(money/1));
money=money%1;
}
});
setSize(350,300);
setVisible(true);
}
class MyItemListener implements ItemListener {
int sum;
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange() == ItemEvent.SELECTED) {
}
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Main extends JFrame{
JCheckBox[] jc = new JCheckBox[7];
JTextField[] tf = new JTextField[8];
public Main(){
JButton b = new JButton("계산");
setTitle("Money Changer with CheckBox");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.setBackground(Color.PINK);
JTextField mtf = new JTextField(20);
c.add(new JLabel("금액 "));
c.add(mtf);
c.add(b);
JLabel[] la = new JLabel[8];
String[] lastr = {"오만원 ","만원 ","천원 ","500원 ","100원 ","50원 ","10원 ","1원 "};
for(int i=0;i<la.length;i++) {
la[i] = new JLabel(lastr[i]);
tf[i] = new JTextField(20);
if(i != 7)
{
jc[i] = new JCheckBox();
}
c.add(la[i]);
c.add(tf[i]);
if(i != 7)
{
c.add(jc[i]);
}
}
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int money = Integer.valueOf(mtf.getText());
//System.out.println(money);
if(jc[0].isSelected()==true)
{
tf[0].setText(Integer.toString(money/50000));
money=money%50000;
}
if(jc[1].isSelected()==true)
{
tf[1].setText(Integer.toString(money/10000));
money=money%10000;
}
if(jc[2].isSelected()==true)
{
tf[2].setText(Integer.toString(money/1000));
money=money%1000;
}
if(jc[3].isSelected()==true)
{
tf[3].setText(Integer.toString(money/500));
money=money%500;
}
if(jc[4].isSelected()==true)
{
tf[4].setText(Integer.toString(money/100));
money=money%100;
}
if(jc[5].isSelected()==true)
{
tf[5].setText(Integer.toString(money/50));
money=money%50;
}
if(jc[6].isSelected()==true)
{
tf[6].setText(Integer.toString(money/10));
money=money%10;
}
tf[7].setText(Integer.toString(money));
}
});
setSize(350,300);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Main extends JFrame{
private JRadioButton [] radiob = new JRadioButton [2];
private String [] names = {"left","right"};
private ImageIcon [] image = {
new ImageIcon("river.png"),
new ImageIcon("river (1).png"),
new ImageIcon("bridge.png"),
};
public Main(){
setTitle("Image Gallery Practice Frame");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
MyMouseListener listener = new MyMouseListener();
for(int i=0; i<radiob.length; i++)
{
radiob[i] = new JRadioButton(names[i]);
c.add(radiob[i]);
radiob[i].addMouseListener(listener);
}
setSize(400,300);
setVisible(true);
}
class MyMouseListener implements MouseListener {
public void MouseStateChanged(ItemEvent e) {
}
public void mouseClicked(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
}
public static void main(String[] args) {
new Main();
}
}
*/