jTable right-click popup menu

前端 未结 3 1642
温柔的废话
温柔的废话 2021-02-05 07:04

I have a SQL database and I am working on a program that will allow me to add/delete/modify records. I already managed to add records I am working on editing/deleting them.

3条回答
  •  花落未央
    2021-02-05 07:39

    Another issue is that context menus are dynamic, your solution does not deal with changing the menu depending on the clicked row

    popupMenu.addPopupMenuListener(new PopupMenuListener() 
    {
       @Override
       public void popupMenuWillBecomeVisible(PopupMenuEvent e) 
       { 
           int rowAtPoint = table.rowAtPoint(SwingUtilities.convertPoint(popupMenu, new Point(0, 0), table));
           generateTablePopupMenu(rowAtPoint); // here
           SwingUtilities.invokeLater(new Runnable() 
               ...
    

提交回复
热议问题