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)