Hello,
So I got the following classes:
Book
BookRegister
GUI
Main
Book contains basic information about what kind of book you want to register. BookRegister contains the linked list for registration. In the GUI, I'm using JList. The thing is, I want to put all my books I register into the JList, and whenever I select one of the books, I want the toString for that book out. Like an information page.
This is a snippet of my code:
private String[] names;
private BookRegister register;
public GUI() {
names = register.getAllBookNames(); // stores all the names into the array.
// methods
}
private class ListListener implements ListSelectionListener {
public void valueChanged(ListSelectionEvent e) {
JList list = (JList)e.getSource();
// I don't know how to select the right book, and get the right toString. Can't find
// any getXXX which returns toString.
}
}
My problem is that I can't get the toString (with all the information about the book) out. I can't find any getXXX methods which returns a String value. I tried getSelectedValues().toString(); but it didn't work so fell. Found out that it returns the title.
How would I do this?
Thanks.