| | |
question on java
![]() |
I assume you are after JavaScript, not Java. Anyway with JavaScript values are not strongly typed, so if the values are numbers, you can use "+".
•
•
•
•
I add integer values in combo box.When I call getSselectedItem it return object.How i convert it into integer.
so, cast it to a String, and parse that to an int.
for instance, you get back an Object with value = "6";
Java Syntax (Toggle Plain Text)
public int objectToInt(Object givenObject){ String inString = (String)givenObject; return Integer.parseInt(inString); }
't voila, instant integer-value. this will only work if the value stored in the object is a valid integer value, so if you have any other data in that list, you may want to catch possible exceptions.
If you added the items as Integer objects:
java Syntax (Toggle Plain Text)
int selectedValue = ((Integer)comboBox.getSelectedItem()).intValue();
![]() |
Similar Threads
- Java's String Tokenizer (Java)
- Question about java.lang.UnsatisfiedLinkError in MMAPI (Java)
- A question on java script?(Please answer ASAP) (Java)
- Question about java.lang.SecurityException (Java)
- having problem with this Question (Java)
- Java Licensing (Java)
Other Threads in the Java Forum
- Previous Thread: How would you go about coding this?
- Next Thread: Java FTP Server
| Thread Tools | Search this Thread |
-xlint actionlistener android api applet application array automation bi binary blackberry block bluetooth character class client code compile compiler component consumer database desktop developmenthelp eclipse error fractal freeze ftp functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide image int j2me j2seprojects java javac javaee javaprojects jetbrains jni jpanel jtable julia learningresources lego linked linux mac main map method mobile myregfun netbeans nonstatic notdisplaying number online pearl printf problem program project qt researchinmotion rotatetext rsa scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows working xor






