Olá. porque que este código não compila , é praticamente um exemplo do use a cabeça java. ele dá erro na linha 19.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author jose
*/
// class Action_Listener {
//}
import javax.swing.*;
import java.awt.event.*; // for ouvir eventos
public class ouvindo implements ActionListener{
JButton botao1;
JButton botao2;
public static void main(String[] args){
ouvindo exemplo = new ouvindo();
exemplo.go();
}
public void go(){
JFrame frame = new JFrame(); // crio um frame
botao1 = new JButton("Button 1");
botao1.addActionListener(this); // botão1 adicionado a lista de ouvintes
botao2 = new JButton("Button 2");
botao2.addActionListener(this); // botão2 adicionado a lista de ouvintes
frame.getContentPane().add(botao1);
frame.getContentPane().add(botao2);
frame.setSize(300,300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void ActionPerformed(ActionEvent event) {
String cmd = event.getActionCommand();
botao1.setText("botao1 Clicado");
if (cmd.equals("Button 2")) {
botao2.setText("botao2 Clicado");
}
}
}
estou usando o netbeans …
sds
j.silvestre