且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Netbeans中的JTable右键单击弹出菜单

更新时间:2023-12-04 10:18:52

为什么要依靠IDE为您生成代码?当您转移到另一个IDE并必须学习如何实现该想法时会发生什么?了解如何编写自己的代码,那么IDE无关紧要:

Why do you rely on an IDE to generate code for you? What happens when you move to a different IDE and you have to learn how to do it for that ide? Learn how to write your own code then the IDE doesn't matter:

table.addMouseListener( new MouseAdapter()
{
    public void mouseReleased(MouseEvent e)
    {
        if (e.isPopupTrigger())
        {
            JTable source = (JTable)e.getSource();
            int row = source.rowAtPoint( e.getPoint() );
            int column = source.columnAtPoint( e.getPoint() );

            if (! source.isRowSelected(row))
                source.changeSelection(row, column, false, false);

            popup.show(e.getComponent(), e.getX(), e.getY());
        }
    }
});