import javax.swing.JButton;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
class Listen implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
JButton rock=(JButton)e.getSource();
}
}
class Frame2 extends JFrame{
JButton asd;
Frame2(){
JPanel p=new JPanel();
asd= new JButton("asd");
p.add(asd);
this.add(p);
setSize(300,300);
setVisible(true);
}
}
class Button1 extends JFrame{
JButton rock, sci, pap;
Button1(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p= new JPanel();
rock=new JButton("바위");
sci= new JButton("가위");
pap= new JButton("보");
rock.addActionListener(new Listen());
p.add(pap);
p.add(rock);
p.add(sci);
this.add(p);
setSize(300,300);
setBackground(Color.DARK_GRAY);
setVisible(true);
rock.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Frame2();
setVisible(false); // 창 안보이게 하기
}
});
}
}
public class Main{
public static void main(String[] args) {
new Button1();
new Frame2();
}
}