Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get selected item from JList by clicking button !

843805Dec 15 2006 — edited Dec 15 2006
hello,

I need one help sir.

If I am clicking one item(IPAddress) from JList , and click Connect button, then the selected item from the list ie. that IP address connects with its corresponding device through SNMP.

For this,

I create an object ,
Object firstSel = jList2.getSelectedValue();
but in snmp , the object is not accepted. it requirs String.

How can I convert Object to string in java.

If I am using string for getSelectedValue() , it gives error.

that is ,
String firstSel = jList2.getSelectedValue();
error is,
mainFrame.java:582: incompatible types

how can i fix this problem.
Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 12 2007
Added on Dec 15 2006
1 comment
420 views