问题描述
- Jmenuitem中怎么实现鼠标监听
- Jmenuitem里面没有mouseClicked方法 要怎样才能实现鼠标监听 获取鼠标点的那个点的坐标
解决方案
Jmenuitem里面没有监mouse方法 JMenu Scanle=new JMenu(""功能"");
Scanle.addMouseListener(new MouseAdapter(){
public void mouseEntered(MouseEvent e){
x=e.getX();
y=e.getY();
}
});
tempItem=new JMenuItem(""光源退化"");
tempItem.addActionListener(new DegradationListener());
tempItem.addMenuDragMouseListener(new MenuDragMouseListener() {
@Override
public void menuDragMouseEntered(MenuDragMouseEvent e) {
throw new UnsupportedOperationException(""Not supported yet.""); //To change body of generated methods choose Tools | Templates.
} @Override public void menuDragMouseExited(MenuDragMouseEvent e) { throw new UnsupportedOperationException(""Not supported yet.""); //To change body of generated methods choose Tools | Templates. } @Override public void menuDragMouseDragged(MenuDragMouseEvent e) { throw new UnsupportedOperationException(""Not supported yet.""); //To change body of generated methods choose Tools | Templates. } @Override public void menuDragMouseReleased(MenuDragMouseEvent e) { // throw new UnsupportedOperationException(""Not supported yet.""); //To change body of generated methods choose Tools | Templates. x=e.getX(); y=e.getY(); } });
做的是图片光源退化 老师要求不要从中心扩散要鼠标选中那里就从那里扩散我这么写实现不了···实在没办法了