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.)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.