Results 1 to 4 of 4
Thread: Radio Button help!
- 04-25-2010, 05:49 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 5
- Rep Power
- 0
Radio Button help!
Ok so I'm creating a Temperature Converter where Im trying to create a command based on the clicked radio button.
rdbtnFtoC is the radio button for converting from Fahrenheit to Celsius.
I want the code to be so that once this option is selected and the convert button is clicked, the value input by the user is converted using a formula.
I'm having trouble saying that if the radio button is selected then execute this code. I don't know if I can use the above if statement in the code,Java Code:public void actionPerformed(ActionEvent evt) { System.out.println("btnConvert.actionPerformed, event="+evt); //TODO add your code for btnConvert.actionPerformed int val = [B]txtInsert.getY()[/B]; if(rdbtnFtoC.equals(true)){ val = ((val-32)*(5/9)); } [B]lblResult.set(val); [/B]
And I'm also having trouble with txtInsert.get (integer) but there seems to be no option for integer :/ and outputting an integer (both in bold)
Help please?
- 04-25-2010, 06:02 PM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
You need to use the "isSelected()" method.I'm having trouble saying that if the radio button is selected then execute this code
- 04-25-2010, 06:15 PM #3
Member
- Join Date
- Mar 2010
- Posts
- 5
- Rep Power
- 0
Ok I tried out the isSelected() method. But I'm still not getting any output :/
Sorry if I seem like such a n00bJava Code:public void actionPerformed(ActionEvent evt) { System.out.println("btnConvert.actionPerformed, event="+evt); int val = txtInsert.getY(); boolean b = rdbtnFtoC.isSelected(); if(b){ int out = ((val-32)*(5/9)); lblResult.equals(out); } boolean c = rdbtnCtoF.isSelected(); if(c){ int out2 = ((val+32)*(9/5)); lblResult.equals(out2); } }
- 04-25-2010, 08:01 PM #4
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Similar Threads
-
Disable Radio button
By AJG in forum New To JavaReplies: 3Last Post: 05-10-2011, 11:09 AM -
Radio button dot color
By Psyclone in forum AWT / SwingReplies: 3Last Post: 02-21-2010, 04:29 AM -
How can I catch the radio button action in jsp?
By srinivas2828 in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 09-18-2009, 04:05 PM -
radio button checked by default
By whiteasshweta in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 07-06-2009, 01:11 PM -
How to use SWT Radio Button
By Java Tip in forum SWTReplies: 0Last Post: 07-25-2008, 02:25 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks