添加了!具体怎么做!
我覆写了
 public void mouseClicked(MouseEvent e){
        if(e.getButton()==3)//如果是鼠标右键点击
              popup.show(table,e.getX(),e.getY());//在table中产生一个popupMenu  }
在这里写,可以实现右击选中table中的行。

解决方案 »

  1.   

    jTable1.addMouseListener
    ...
    查查API,再试试就OK了,别忘了判断mouse按钮的类型哟,如果是右键再执行你的方法
      

  2.   

    楼上的打哥,我已经jTable1.addMouseListener
    并且自己撰写了class RightClick extends MouseAdapter,在这里我覆写了mouseClicked方法
    要是查API我自己可以搞定我就不发帖子了。
    我想问在覆写
    public void mouseClicked(MouseEvent e){
            if(e.getButton()==3)//如果是鼠标右键点击
                  popup.show(table,e.getX(),e.getY());//在table中产生一个popupMenu  }
    怎么可以可以实现右击选中table中的行。是在这个方法里写吗。
    我现在已经让table接受了鼠标事件。我怎么让他接受我所选的行。
    用不用到ListSelectionEvent????
      

  3.   

    table.setRowSelectionInterval(int startRow, int lastRow);选右键点击的行,就是先提取点击的行号,然后用上面的方法选择
      

  4.   

    public void mouseReleased(MouseEvent e)
    {
    if(e.isPopupTrigger())
    {
    if(popup == null) return;
    int row = table.rowAtPoint(e.getPoint());
    int column = table.columnAtPoint(e.getPoint());
    if(row >= 0 && column >= 0)
    {
    table.requestFocus();
    table.changeSelection(row, column, false, false);
    popup.show(table, e.getX(), e.getY());
    } }
    }