我有一个JList:如何显示悬停在JList项目上的JLabel?
comandaListModel = new SortedListModel<String>();
comandaListScrollPane = new JScrollPane();
comandaPanel.add(comandaListScrollPane, BorderLayout.CENTER);
comandaList = new JList<String>(comandaListModel);
comandaListScrollPane.setViewportView(comandaList);
而且我有一个自定义的JLabel类:
public class QrCodeLabel extends JLabel {
public Image qrCode;
public QrCodeLabel(JList list) {
super("");
updateQrCode(list);
}
public void updateQrCode(JList list) {
if (ComandaCreationFrame.getQrMatrixes() != null) {
this.qrCode = QRGenerator.generateImage(ComandaCreationFrame.getQrMatrixes().get(list.getSelectedValue())).getScaledInstance(this.getWidth(), this.getHeight(), Image.SCALE_SMOOTH);
this.setIcon(new ImageIcon(this.qrCode));
}
}
}
JLabel将大干快上的Jlist的ListSelectionListener
的valueChanged
更新。我怎样才能“弹出”JLabel将鼠标悬停在JList的每个项目上?是否有可能为JList实现这种“工具提示”功能? (当然,通过“显示”一个JLabel,它也可能意味着一个带有JLabel的JPanel)。
['JToolTip'](http://docs.oracle.com/javase/8/docs/api/javax/swing/JToolTip.html) –