它第一次工作但在删除某些行后,右键单击弹出菜单显示为空白。我认为它是因为刷新方法,但我无法解决它。
private void refresh() {
List<String> head = new ArrayList<>();
head.add("ID");
head.add("П/Н");
EnlargeAlisTableModel model = new EnlargeAlisTableModel(dbsql.listAlis(), head) {
// *****************
};
tblEnlarge.setModel(model);
tblEnlarge.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
popup.removeAll();
JMenuItem delete = new JMenuItem("Delete");
delete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (tblEnlarge.getSelectedRow() == -1) {
} else {
DeleteEnlargeAlis da = new DeleteEnlargeAlis(null, true, Integer.parseInt(tblEnlarge.getValueAt(tblEnlarge.getSelectedRow(), 0).toString()));
da.setVisible(true);
if (da.isOk()) {
Ok = true;
refresh();
}
}
}
});
// ********************
popup.add(delete);
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
});