|
-
Hi!, can anyone help me on Applet, Please!!!
Hello!,
If anyone can read this please help me on this, Please!
I have an Applet Code and the only problem is that the total of two number will not display and If anyone can read this please! help me.
the Applet Code is here:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Compute extends Applet implements ActionListener
{
TextField txtunit,txtrate,txttotal;
Button cmdAdd, cmdMultiply, cmdSubtract, cmdDivide;
Label ato,babe,cam;
double Total;
Font newFont = new Font("Verdana",Font.BOLD,12);
public void init()
{
this.setForeground(SystemColor.control);
this.setBackground(SystemColor.control);
ato = new Label("Enter a Number:");
ato.setFont(newFont);
ato.setForeground(Color.red);
txtunit = new TextField(7);
txtunit.setBackground(Color.blue);
txtunit.setForeground(Color.yellow);
add(ato);
add(txtunit);
babe = new Label("Enter a Number:");
babe.setFont(newFont);
babe.setForeground(Color.blue);
txtrate = new TextField(7);
txtrate.setBackground(Color.yellow);
txtrate.setForeground(Color.red);
add(babe);
add(txtrate);
cam = new Label("Total");
cam.setFont(newFont);
cam.setForeground(Color.red);
txttotal = new TextField(7);
txttotal.setBackground(Color.blue);
txttotal.setForeground(Color.yellow);
add(cam);
add(txttotal);
cmdAdd = new Button("Add");
cmdMultiply = new Button("Multiply");
cmdSubtract = new Button("Subtract");
cmdDivide = new Button("Divide");
cmdAdd.setForeground(Color.blue);
cmdMultiply.setForeground(Color.blue);
cmdSubtract.setForeground(Color.blue);
cmdDivide.setForeground(Color.blue);
add(cmdAdd);
add(cmdSubtract);
add(cmdMultiply);
add(cmdDivide);
cmdAdd.addActionListener(this);
cmdMultiply.addActionListener(this);
cmdSubtract.addActionListener(this);
cmdDivide.addActionListener(this);
}
public void actionPerformed(ActionEvent AlcioAbaquita)
{
if(AlcioAbaquita.getSource() == cmdMultiply)
{
Total = Double.parseDouble(txtunit.getText()) * Double.parseDouble(txtrate.getText());
txttotal.setText(String.valueOf(Total));
}
else if(AlcioAbaquita.getSource() == cmdAdd)
{
Total = Double.parseDouble(txtunit.getText()) + Double.parseDouble(txtrate.getText());
txttotal.setText(String.valueOf(Total));
}
else if(AlcioAbaquita.getSource() == cmdDivide)
{
Total = Double.parseDouble(txtunit.getText()) / Double.parseDouble(txtrate.getText());
txttotal.setText(String.valueOf(Total));
}
else if(AlcioAbaquita.getSource() == cmdSubtract)
{
Total = Double.parseDouble(txtunit.getText()) - Double.parseDouble(txtrate.getText());
txttotal.setText(String.valueOf(Total));
}
}
}
Similar Threads
-
By Tataroz T. in forum Java
Replies: 1
Last Post: 10-20-2005, 06:19 AM
-
By Charlie Flynn in forum Java
Replies: 3
Last Post: 08-23-2001, 11:01 AM
-
Replies: 0
Last Post: 05-06-2000, 10:38 PM
-
Replies: 0
Last Post: 05-06-2000, 10:36 PM
-
Replies: 0
Last Post: 03-28-2000, 01:52 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks