/* only must track item of mouse-over.then use locationToIndex(Point) for
turn point to item of list , then you list.setToolTipText(relatedValue)*/
private class MyJList extends JList {
int itemIndexUnderMouse;
public MyJList(Object[] values) {
super(values);
itemIndexUnderMouse = -1;
addMouseMotionListener(new MouseMotionAdapter() {
public void mouseMoved(MouseEvent e) {
Point point = indexToLocation(0);
int index = locationToIndex(e.getPoint());
if (index != itemIndexUnderMouse ||
itemIndexUnderMouse == -1) {
updateToolTip(index);
}
}
});
}
private void updateToolTip(int index) {
String newToolTip = (String) (getModel().getElementAt(index));
// or each thing that you want
setToolTipText(newToolTip);
}
}