Por que o botão não esta funcionando ?, não entra no if ?
import javax.swing.<em>;
import java.awt.</em>;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Calculo extends JFrame implements ActionListener{
JLabel nome;
JButton btn;
JTextField txt;
Calculo()
{
super(“Mandar Nome”);
JLabel nome = new JLabel ("Nome: ");
JTextField txt = new JTextField (50);
JButton btn = new JButton(“Mandar Nome”);
setLayout(new FlowLayout());
add(nome);
add(txt);
add(btn);
setVisible(true);
pack();
btn.addActionListener(this);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Calculo c = new Calculo();
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==btn)
{
txt.setText("");
}
}
}