Good day,
I have created the Applet but i don't know how to code the button to work or addActionListen er. See below
I have created the Applet but i don't know how to code the button to work or addActionListen er. See below
Code:
import java.applet.Applet;
import java.awt.TextField;
import java.awt.Button;
import java.awt.Label;
import java.awt.Graphics;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Vivz extends Applet implements ActionListener{
Label lblProduct;
Label lblPrice;
Label lblQuantity;
TextField txtProduct;
TextField txtPrice;
TextField txtQuantity;
Button btnCalculate;
String total = "";
public void init()
{
lblProduct = new Label("Enter the product ");
txtProduct = new TextField(20);
lblPrice = new Label("Enter the price ");
txtPrice = new TextField(20);
lblQuantity = new Label("Enter the quantity ");
txtQuantity = new TextField(20);
btnCalculate = new Button("Calculate Invoice");
btnCalculate.addActionListener(this);
add(lblProduct);
add(txtProduct);
add(lblPrice);
add(txtPrice);
add(lblQuantity);
add(txtQuantity);
add(btnCalculate);
add(lblResult);
}
public void actionPerformed(ActionEvent e)
{
}
}
Comment