6 Replies - 3999 Views - Last Post: 23 July 2009 - 09:17 PM Rate Topic: -----

#1 khaa_khay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-July 09

set RadioButton value

Posted 22 July 2009 - 08:58 PM

Hellow aLL,,

I save value from database to string
String gender = rs.getString();
if (gender.equals("male"))
{
	 jRadioButton1.setSelected(true);   
}



it's not getting error
but why jRadioButton can't set true ?

i have tried to used
if (gender=="male"))



but it'is still same

Is This A Good Question/Topic? 0
  • +

Replies To: set RadioButton value

#2 syfran  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 83
  • View blog
  • Posts: 1,103
  • Joined: 12-July 09

Re: set RadioButton value

Posted 22 July 2009 - 09:00 PM

Instead of using if (gender == "male")) use if (gender.equals("male"))
Crap I need to learn to read...

We need more information about you're problem to help.

This post has been edited by syfran: 22 July 2009 - 09:07 PM

Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8328
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: set RadioButton value

Posted 22 July 2009 - 09:07 PM

I have to have a "cut & paste" topic about that
you CANNOT use == to compare 2 Strings
Was This Post Helpful? 0
  • +
  • -

#4 syfran  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 83
  • View blog
  • Posts: 1,103
  • Joined: 12-July 09

Re: set RadioButton value

Posted 22 July 2009 - 09:09 PM

View Postpbl, on 22 Jul, 2009 - 08:07 PM, said:

I have to have a "cut & paste" topic about that
you CANNOT use == to compare 2 Strings


I think hes saying he tried both... I think.
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8328
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: set RadioButton value

Posted 22 July 2009 - 09:16 PM

optimized code would be

jRadioButton1.setSelected(gender.equals("male");

but I must ahve miss something in your question
Was This Post Helpful? 0
  • +
  • -

#6 khaa_khay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-July 09

Re: set RadioButton value

Posted 23 July 2009 - 03:28 AM

okay,,


my question is,,
how i can set value to radiobutton from database ?
i have used == and .equals
but radio button not set yet,,
Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8328
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: set RadioButton value

Posted 23 July 2009 - 09:17 PM

that should work

jRadioButton1.setSelected(gender.equals("male");

cannot tell you more unless you give us more details on your context
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1