私が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
に更新されます。 JListの各項目の上にマウスを置いてJLabelを "ポップアップ"するにはどうすればいいですか?このような「ツールチップ」機能をJListに実装することは可能ですか? (JLabelを「表示」することで、もちろんJLabelを持つJPanelを意味することもあります)。
['JToolTip'](http://docs.oracle.com/javase/8/docs/api/javax/swing/JToolTip.html) –