Java - "Boton" cannot be resolved to a variable

 
Vista:
sin imagen de perfil

"Boton" cannot be resolved to a variable

Publicado por Damian (4 intervenciones) el 31/08/2017 16:28:26
Buenas gente quería ver si alguien me puede ayudar con un problema, estoy creando una ventana y quiero que al presionar los botones estos realicen acciones (nada loco), los creo les doy el addActionListener y desmas, pero cuando intento crear un metodo Action performed me da el error que dice en el título.

Este es el código:

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import javax.swing.JPanel;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
 
 
public class botonesInicio extends JPanel implements ActionListener{
 
	/**
	 * Create the panel.
	 */
	public botonesInicio() {
		setLayout(new GridLayout(4, 3, 5, 5));
 
		JLabel label = new JLabel("");
		add(label);
 
		JLabel label_1 = new JLabel("");
		add(label_1);
 
		JLabel label_2 = new JLabel("");
		add(label_2);
 
		JLabel label_3 = new JLabel("");
		add(label_3);
 
		JButton btnBuscar = new JButton("Buscar");
		add(btnBuscar);
		btnBuscar.addActionListener(this);
 
		JLabel label_4 = new JLabel("");
		add(label_4);
 
		JLabel label_5 = new JLabel("");
		add(label_5);
 
		JButton btnAñadir = new JButton("A\u00F1adir");
		add(btnAñadir);
		btnAñadir.addActionListener(this);
 
		JLabel label_6 = new JLabel("");
		add(label_6);
 
		JLabel label_7 = new JLabel("");
		add(label_7);
 
		JLabel lblThedergonStudio = new JLabel("TheDERGON Studio");
		lblThedergonStudio.setEnabled(false);
		lblThedergonStudio.setFont(new Font("Tahoma", Font.PLAIN, 7));
		lblThedergonStudio.setHorizontalAlignment(SwingConstants.CENTER);
		add(lblThedergonStudio);
 
		JLabel label_9 = new JLabel("");
		add(label_9);
 
	}
	public void ActionPerformed(ActionEvent evento)
	{
		if(evento.getSource() == btnBuscar) <--------------------------------Aca tira error
		{
			this.setVisible(false);
		}
		if(evento.getSource() == btnAñadir) <--------------------------------Aca tira error
		{
 
		}
	}
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder