| | |
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 |
911 addball addressbook android api append applet application apps array arrays automation binary bluetooth businessintelligence button card class client code collision component crashcourse css csv database eclipse ee error fractal free ftp game gis givemetehcodez graphics gui html ide image integer integration j2me japplet java javaarraylist javadoc javafx javaprojects jni jpanel julia jvm linked linux list loan machine map method methods migrate mobile netbeans objects oriented output phone physics printf problem program programming project projects radio recursion replaydirector reporting researchinmotion rotatetext scanner se server service set sms software sort sql string swing test textfield threads tree trolltech ubuntu utility windows






