twc
Posts: 129
Nickname: twc
Registered: Feb, 2004
|
|
Re: Get string from icon and string list
|
Posted: Feb 28, 2004 2:06 PM
|
|
The message "cannot resolve symbol" means that the compiler cannot find a method by the name of getText() in the Object class. If you look at the documentation of the Object class, you will see that it doesn't contain any such method. Which is why you got the message.
The method returns an Object because Object is the most generic of all object types. However, what is being returned is more than a plain-vanilla Object. You need to cast it to whatever it actually is. Without seeing your actual code, I can't be sure what to cast to. But according to the documentation of JList, it appears that the individual cells are rendered as JLabel's.
Try something like this first.
JLabel personValue = (JLabel) personList.getSelectedValue();
System.out.println(personValue.getText());
If that doesn't work, you may need to post more code.
|
|