Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: need help .. what is wrong with my code.

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post need help .. what is wrong with my code.

    Hi,
    i m beginner and working on my assignement write code of a weight calculation base on person's heaight..

    code have 2 JRadio Button and 1 JSlider
    JR Buttons:
    "Male"
    "female"
    change event & action command set on both buttons.
    and actionlistener. on slider.

    code compile and app run successfully but with slider movement just 1 formula is working. nothing show the changes when in change the button with click .. male >> female.
    here is a bit of both part of code for buttons & slider:

    public void actionPerformed(ActionEvent ae) {

    if("Female".equals(ae.getActionCommand())) {
    if(f.isSelected() ); // f is name of JRadio buttom "Female" is setActionCommand("Female"), m is name of male button
    jb2 = f.getText();

    }
    } // end of action performed

    public void stateChanged( ChangeEvent evt )
    {

    JSlider source = (JSlider)evt.getSource();

    if ( !source.getValueIsAdjusting( )) {
    sl = source.getValue();
    h = sl*sl;
    } // End of if line 6

    // jb2 (string reference from change event)

    if(evt.getSource() ==jb2){
    h3 = h/30;
    ans2 = h3 +"";
    textA.setText(ans2);

    }else {
    h2 = h/28;
    ans = h2 +"";
    textA.setText(ans);
    } // End of else for

    }

    (else is not in work)
    jb2 is string where store the button value(name)
    sl is integer and getting value from slider

    h, h2, h3 are int

    please Help me.
    Thanks
    (sorry for bad English)


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,550
    My Mood
    Grumpy
    Thanks
    0
    Thanked 169 Times in 160 Posts

    Default Re: need help .. what is wrong with my code.

    Problem with action performing !!

    Duplicate post!

    They have already been given lots and lots of help.
    Improving the world one idiot at a time!

Similar Threads

  1. what is wrong with my code?
    By bmb in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 7th, 2011, 10:03 AM
  2. What is wrong in the code
    By Rajiv in forum JavaServer Pages: JSP & JSTL
    Replies: 4
    Last Post: July 29th, 2011, 01:09 PM
  3. what's wrong with this code
    By gcsekhar in forum Java Networking
    Replies: 5
    Last Post: July 21st, 2011, 07:01 AM
  4. what's wrong with my code
    By gcsekhar in forum Java Networking
    Replies: 2
    Last Post: July 19th, 2011, 10:31 AM
  5. what is wrong in this code
    By rk.kavuri in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 6th, 2011, 03:13 PM