怎么在List中添加JPopupMenu?
添加了但是显示不了,很奇怪?
------解决方案--------------------
jTable1.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if(e.getButton()==3){
showMenu(e.getX(),e.getY());
}
}
});
protected void showMenu(int x,int y) {
JPopupMenu popup=new JPopupMenu();
JMenuItem jItem2=new JMenuItem("增加");
JMenuItem jItem3=new JMenuItem("修改");
JMenuItem jItem4=new JMenuItem("删除");
popup.add(jItem2);
popup.add(jItem3);
popup.add(jItem4);
popup.show(jTable1,x,y);
}