/*
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main extends JFrame {
private JButton [] Ibtn = new JButton [3];
private JLabel la = new JLabel();
private JLabel la1 = new JLabel();
private JLabel la2 = new JLabel();
private JLabel la3 = new JLabel();
private JLabel la4 = new JLabel();
private ImageIcon [] image = {
new ImageIcon("images/scissors.png"),
new ImageIcon("images/motivation.png"),
new ImageIcon("images/palm.png")
};
public Main() {
setTitle("가위 바위 보 게임");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
JPanel p = new JPanel();
c.setBackground(Color.yellow);
p.setBackground(Color.GRAY);
c.add(p);
ButtonGroup g = new ButtonGroup();
for(int i=0; i<Ibtn.length; i++)
{
Ibtn[i] = new JButton(image[i]);
g.add(Ibtn[i]);
p.add(Ibtn[i]);
Ibtn[i].addActionListener(new MyActionListener());
}
c.add(la);
c.add(la1);
c.add(la2);
c.add(la3);
c.add(la4);
setSize(350, 300);
setVisible(true);
la.setVisible(true);
la.setLocation(200,150);
la1.setVisible(true);
la1.setLocation(200,150);
la2.setVisible(true);
la2.setLocation(200,150);
la3.setVisible(true);
la3.setLocation(200,150);
la4.setVisible(true);
la4.setLocation(200,150);
}
class MyActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
int x = (int) (Math.random()*3);
JButton pressed_Button = (JButton)e.getSource();
if(pressed_Button.equals(Ibtn[0]))
{ //me : 가위
la.setIcon(image[0]);
if(x==0) la4.setText("Same!!!");
else if(x==1) la4.setText("Computer!!!");
else la4.setText("Me!!!");
}
else if(pressed_Button.equals(Ibtn[1]))
{ //me : 바위
la.setIcon(image[1]);
if(x==1) la4.setText("Same!!!");
else if(x==2) la4.setText("Computer!!!");
else la4.setText("Me!!!");
}
else
{ //me : 보
la.setIcon(image[2]);
if(x==2) la4.setText("Same!!!");
else if(x==0) la4.setText("Computer!!!");
else la4.setText("Me!!!");
}
la1.setText("me");
la2.setIcon(image[x]);
la3.setText("com");
la4.setForeground(Color.red);
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main extends JFrame {
int goal = 5;
private JLabel [] la = new JLabel[goal];
private JLabel jla = new JLabel();
private JButton y = new JButton("y");
private JButton n = new JButton("n");
int num=0;
Container c = getContentPane();
public void reset() {
jla.setVisible(false);
y.setVisible(false);
n.setVisible(false);
for(int i=0; i<la.length; i++)
{
int x = (int)(Math.random()*300);
int y = (int)(Math.random()*300);
la[i].setLocation(x, y);
la[i].setVisible(true);
}
}
public Main() {
setTitle("Ten 레이블 클릭");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
c.setLayout(null);
y.setVisible(false);
n.setVisible(false);
for(int i=0; i<la.length; i++)
{
la[i] = new JLabel(Integer.toString(i));
la[i].addMouseListener(new MyMouseListener());
la[i].setSize(10,10);
int x = (int)(Math.random()*300);
int y = (int)(Math.random()*300);
la[i].setLocation(x, y);
c.add(la[i]);
}
jla.setLocation(120,100);
jla.setSize(200,100);
jla.setVisible(true);
c.add(jla);
c.add(y);
c.add(n);
y.setSize(44, 44);
y.setLocation(110, 170);
y.setVisible(false);
n.setSize(44,44);
n.setLocation(220,170);
n.setVisible(false);
y.addActionListener(new MyActionListener());
n.addActionListener(new MyActionListener2());
setSize(400, 400);
setVisible(true);
}
class MyMouseListener extends MouseAdapter{
public void mousePressed(MouseEvent e) {
//int result = JOptionPane.showConfirmDialog(null, "게임을 다시 하시겠습니까?","Confirm", JOptionPane.YES_NO_OPTION);
JLabel pl = (JLabel)e.getSource();
int plnum = Integer.parseInt(pl.getText());
if(plnum==num)
{
num++;
pl.setVisible(false);
}
if(num==goal)
{
jla.setVisible(true);
jla.setText("게임을 다시 하시겠습니까?");
y.setVisible(true);
n.setVisible(true);
num=0;
}
}
}
class MyActionListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
reset();
}
}
class MyActionListener2 implements ActionListener{
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
public static void main(String[] args) {
new Main();
}
}
*/