public static void populateJList(JList list) {
ArrayList<String> contents= DataAccess.getContents();
DefaultListModel listModel = new DefaultListModel();
for (String string : contents) {
listModel.addElement(string);
}
preset.setModel(listModel);
}
I have this method that populates my JList, is there a way that I can add toolTipText
of every item in the JList?
For JDK >= 1.6, a slightly different construction is needed:
You can override the getToolTipText(..) method of the JList.
I believe you can also use a custom renderer which invokes the setToolTipText(...) method.
If you don't want to override
JList
, you can use aMouseMotionAdapter
to change the tooltip text