0

它是第一次工作,但在删除某些行后,它在右键单击的弹出菜单上显示为空白。我认为这是因为刷新方法,但我无法解决它。

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());
            }
        }
    });
4

0 回答 0