Ejemplo n.º 1
0
    public void mouseClicked(MouseEvent ev) {
      Window w = (Window) ev.getSource();
      Frame f = null;

      if (w instanceof Frame) {
        f = (Frame) w;
      } else {
        return;
      }

      Point convertedPoint = SwingUtilities.convertPoint(w, ev.getPoint(), getTitlePane());

      int state = f.getExtendedState();
      if (getTitlePane() != null && getTitlePane().contains(convertedPoint)) {
        if ((ev.getClickCount() % 2) == 0 && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) {
          if (f.isResizable()) {
            if ((state & Frame.MAXIMIZED_BOTH) != 0) {
              f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH);
            } else {
              f.setExtendedState(state | Frame.MAXIMIZED_BOTH);
            }
            return;
          }
        }
      }
    }
 void forwardEventToParent(MouseEvent e) {
   getParent()
       .dispatchEvent(
           new MouseEvent(
               getParent(),
               e.getID(),
               e.getWhen(),
               e.getModifiers(),
               e.getX(),
               e.getY(),
               e.getXOnScreen(),
               e.getYOnScreen(),
               e.getClickCount(),
               e.isPopupTrigger(),
               MouseEvent.NOBUTTON));
 }