| | |
question on java
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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
Views: 385 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Java
account android api apple applet application arguments array arrays automation binary bluetooth calculator chat class classes client code component data database draw eclipse error errors event exception file filechooser fractal game givemetehcodez google graphics gui helpwithhomework homework html ide image inheritance input integer j2me java javaprojects jlabel jmf jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile monitoring netbeans newbie nullpointerexception number object open-source oracle print problem program programming project property recursion ria scanner screen search server set size sms socket sort sourcelabs splash sql sqlite static string support swing test testautomation threads time transfer tree windows






