É o seguinte tenho uma applet e tenho um txt com evento para calcular e um botão para limpar, queria saber como faço um evento para o botão limpar, pois ja fiz utilizei um evento agora queria trabalhar com dois eventos:
segue o código:
import javax.swing.;
import java.awt.event.;
import java.awt.*;
public class CubeText extends JApplet implements ActionListener {
JLabel label1;
JTextField txt1;
JButton bt1;
public void init(){
Container tela = getContentPane();
tela.setLayout(new FlowLayout() );
label1 = new JLabel("Entre com os valores em Radium");
txt1 = new JTextField(10);
txt1.addActionListener(this);
bt1 = new JButton("Limpar");
//bt1.addActionListener(this);
tela.add(label1);
tela.add(txt1);
tela.add(bt1);
}
public void actionPerformed(ActionEvent e)
{
double radius = Double.parseDouble(e.getActionCommand());
showStatus("Volume is "+calcu_vol(radius));
}
public double calcu_vol(double radius)
{
double volume = (4.0/3.0)*Math.PI * Math.pow(radius,3);
return volume;
}
}