2014-01-30 57 views

回答

0

我已經解決了我的問題是這樣的:

public class MyMenuItem extends JMenuItem { 

    public MyMenuItem(String text) { 
     super(text); 
    } 

    @Override 
    protected void processMouseEvent(MouseEvent evt) { 
     if (evt.getID() == MouseEvent.MOUSE_RELEASED && contains(evt.getPoint())) { 
      doClick(); 
      setArmed(true); 
     } else 
      super.processMouseEvent(evt); 
    } 

}