-
Notifications
You must be signed in to change notification settings - Fork 1
/
Carta.java
59 lines (51 loc) · 1.4 KB
/
Carta.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package combinado1;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
public class Carta extends JFrame
{
private static final long serialVersionUID = 1L;
private Button b0,b1,b2;
public int con = 0;
public Carta()
{
super("CARTA");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new BorderLayout());
Panel botonera = _crearBotonera();
add(botonera, BorderLayout.CENTER);
setSize(300,300);
}
private Panel _crearBotonera()
{
b0 = new Button("0");
b1 = new Button("1");
b2 = new Button("2");
b0.addActionListener(new EscuchaBoton());
b1.addActionListener(new EscuchaBoton());
b2.addActionListener(new EscuchaBoton());
Panel p = new Panel(new GridLayout(3,1));
p.add(b0);
p.add(b1);
p.add(b2);
return p;
}
class EscuchaBoton implements ActionListener{
public void actionPerformed(ActionEvent e){
if (con == 0){
System.out.println("Hola...");
con++;
}else{
MenuCartas nuevo = new MenuCartas();
nuevo.setVisible(true);
}
}
public void main(String[] args)
{
Carta l1 = new Carta();
l1.setBounds(0, 0, 360, 480);
l1.setVisible(true);
}
}
}