Results 1 to 11 of 11

Thread: Debug Please

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    USA
    Posts
    432

    Angry Debug Please

    Code:
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    
    public class Charge extends Applet implements ActionListener
    {
      Label lblPackage_ID = new Label("Package ID# ");
      Label lblPackage_Pounds = new Label("Package Pounds");
      Label lblPackage_Ounces = new Label("Package Ounces");
      Label lblPackage_Pounds_Total = new Label(" ");
      Label lblPackage_Ounces_Total = new Label(" ");
      Label lblError = new Label("Error");
      TextField txtPackage_ID = new TextField("154496P");
      TextField txtPounds = new TextField("0");
      TextField txtOunces = new TextField("5");
      Button btnCalculate = new Button("Calculate");
      //Declair Var's
      final float fltSCharge = 0.12f;
      final float fltCharge = 1.92f;
      float fltPounds_Calculation;
      float fltOunces_Calculation;
      String strPounds;
      String strOunces;
    
      public void init()
      {
        setBackground(Color.darkGray);
        add(lblPackage_ID);
        add(txtPackage_ID);
        add(lblPackage_Pounds);
        add(txtPounds);
        add(lblPackage_Ounces);
        add(txtOunces);
        add(btnCalculate);
        lblError.setForeground(Color.red);
        add(lblError);
        add(lblPackage_Pounds_Total);
        add(lblPackage_Ounces_Total);
      }
      public void actionPerformed(ActionEvent p1)
      {
    
        float fltPounds = Float.valueOf(txtPounds.getText()).floatValue();
        float fltOunces = Float.valueOf(txtOunces.getText()).floatValue();
        NumberFormat fmtDecimal = NumberFormat.getInstance();
        fmtDecimal.setMaximumFractionDigits(2);
        fmtDecimal.setMinimumFractionDigits(2);
        NumberFormat fmtCurrency = NumberFormat.getCurrencyInstance();
        if (fltPounds > 0)
        {
          fltPounds_Calculation = fltPounds * fltCharge;
        }
        if (fltOunces > 0)
        {
          fltOunces_Calculation = fltOunces * fltSCharge;
        }
        strPounds = String.valueOf(fltPounds_Calculation);
        strOunces = String.valueOf(fltOunces_Calculation);
        lblPackage_Pounds_Total.setText(strPounds);
        lblPackage_Ounces_Total.setText(strOunces);
    
      }
    }
    Its not displaying the Result in the Labels?
    Last edited by 308holes; Sep 21st, 2002 at 08:50 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width