Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JList Problem

Status
Not open for further replies.

shangrilla

Programmer
Nov 21, 2001
360
US
How can I convert customerList.getSelectedValue() to a string which I have pass to method as an argument.
 
This depends on your model. If youre using DefaultListModel and you are putting Strings inside then

customerList.getSelectedValue().toString()

will work for you.

If you have a custom model, say customerModel which has a method getCustomer(int id) you would use the following to extract the name of the customer e.g.

int selected = customerList.getSelectedIndex()
customerModel.getCustomer(selected).getName()

(This is the wrong forum. Go to the general Java Forum.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top