Results 1 to 4 of 4
Thread: Help with combo box
- 10-26-2011, 05:46 PM #1
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Help with combo box
Hello I want to do an if statement that says if the user chooses Female it must do something and if the user chooses Male it must also do something. Help would very much appreciated! here is the code:
Java Code:private void comboBox1MouseClicked(MouseEvent e) { if (comboBox1 == "Female") { //do something } else { if (comboBox1 == "Male") { //do something } } }
- 10-26-2011, 06:12 PM #2
Member
- Join Date
- Oct 2011
- Posts
- 14
- Rep Power
- 0
Re: Help with combo box
Java Code:if(comboBox1.getSelectedItem().equals("Female") { // do something } else if(comboBox1.getSelectedItem().equals("Male") { // do something }
-
Re: Help with combo box
- Don't check Strings for equality with ==, but instead use the equals(...) method.
- Check out and use the "else if" construct.
edit: as SRaith states above!
- 10-26-2011, 06:30 PM #4
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Similar Threads
-
dynamically populate the city combo box based on the values of state combo +ajax+jsp
By sandy1000 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 12-29-2010, 10:00 AM -
Combo Box
By efozdel in forum New To JavaReplies: 1Last Post: 07-07-2010, 03:29 PM -
help get the value from the combo box
By archcavalier in forum Enterprise JavaBeans (EJB)Replies: 7Last Post: 05-23-2010, 06:03 PM -
creation of one combo box form another combo box
By er.tyagigaurav in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 12-09-2008, 03:14 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks