Results 1 to 3 of 3
  1. #1
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Question [SOLVED] Radio Buttons

    :confused:

    I have completed a project using radio buttons that runs fine using the following script

    Java Code:
    double inch = 0;
            double kg;
            double lbs = 0;
            double cm;
            double outputInches;
            double outputLbs = 0;
            boolean ok;
            ok = true;
            String outinch;
            String outlbs;
    
            // try catch for numeric data only
                    try {
                    cm = Double.parseDouble(txtCm.getText());//expect any numerical input
                   }
               catch (NumberFormatException n)  {//to catch none numeric input
                    Optpane.showMessageDialog(this,"Enter numbers only please",
                    "please re-enter",Optpane.ERROR_MESSAGE); // Optpane kicks in on error
                    ok = false; //boolean to trigger Optpane on alpha entry
                   }
    
    // start of formula to convert cm to inches and inches to cm - uses class file Units.java
    
                    cm=Double.parseDouble(txtCm.getText());
    
    
                    outputInches = RbMetric.RadioButtExercise(cm,inch);
                                   // Class.PackageName
    
                    txtInch.setText(outinch=conversions.format(outputInches));
    
                    
    // End of formula
    So my way of thinking says that apart from the variables and package names everything should work in whatever package.

    However the following code gives me an error, 'Cannot find symbol, Symbol:Method Bmi31(Double,Double), Location Class bmi31.MetricCm.bmi31, Required Double, Variable inches might not have been initialized.'

    Java Code:
    double inchs = 0;
            double cms;
            double outputInches;
            boolean ok;
            ok = true;
            String outinch;
    
            // try catch for numeric data only
                    try {
                    cms = Double.parseDouble(txtHeight.getText());//expect any numerical input
                   }
               catch (NumberFormatException n)  {//to catch none numeric input
                    optPane1.showMessageDialog(this,"Enter numbers only please",
                    "please re-enter",optPane1.ERROR_MESSAGE); // Optpane kicks in on error
                    ok = false; //boolean to trigger Optpane on alpha entry
                   }
    
    // start of formula to convert cm to inches and inches to cm - uses class file Units.java
    
                    cms=Double.parseDouble(txtHeight.getText());
    
    
                    outputInches = MetricCm.bmi31(cms,inchs);
                                   // Class.PackageName
    
                    txtConvHeight.setText(outinch=bodymass.format(outputInches));
    
    
    // End of formula
    I ran the clean build then the initialise error disappeared but the rest is still there, I do not understand why it is telling me i need a double for the class that contains the formula, the program that works does not have it.

    Can someone advise me what the problem is please

    Thanks in advance.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Does the MetricCm class have a static method bmi31? If so, perhaps you want to show it to us.

    I don't see a variable called "inches" though.

  3. #3
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Thumbs up

    Thanks, I was kind of missing a big chucnk of code for what I wanted just didnt notice......

    :D

Similar Threads

  1. Deselect Radio Buttons
    By linux1man in forum AWT / Swing
    Replies: 7
    Last Post: 03-21-2009, 04:01 AM
  2. [B]Tab Sequence problem with radio buttons[/B]
    By shobha2k8 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 08-25-2008, 07:25 AM
  3. How to use Radio Buttons
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-25-2008, 02:26 PM
  4. radio buttons and paint
    By gtraylo in forum Java Applets
    Replies: 1
    Last Post: 04-19-2008, 12:43 PM
  5. property for radio buttons
    By swapnanair in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 12-03-2007, 08:39 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
  •