Ejemplo n.º 1
0
  @Override
  public void setPressed(boolean b) {
    if ((isPressed() == b) || !isEnabled()) {
      return;
    }

    if (!b && isArmed()) {
      updateState();
    }

    if (b) {
      stateMask |= PRESSED;
    } else {
      stateMask &= ~PRESSED;
    }

    fireStateChanged();

    if (!isPressed() && isArmed()) {
      int modifiers = 0;
      AWTEvent currentEvent = EventQueue.getCurrentEvent();
      if (currentEvent instanceof InputEvent) {
        modifiers = ((InputEvent) currentEvent).getModifiers();
      } else if (currentEvent instanceof ActionEvent) {
        modifiers = ((ActionEvent) currentEvent).getModifiers();
      }
      fireActionPerformed(
          new ActionEvent(
              this,
              ActionEvent.ACTION_PERFORMED,
              getActionCommand(),
              EventQueue.getMostRecentEventTime(),
              modifiers));
    }
  }
Ejemplo n.º 2
0
 // MDM - When the window is resizing, the layout and painting have to take place
 // immediately.  Otherwise, the window flashes and flickers annoyingly.
 // The best way to tell if the window is being resized (as far as I can tell), is to
 // check the currentEvent in the EventQueue. I didn't see anything in particular about
 // the event that tells us what's happening.
 private boolean isWindowResizing() {
   return EventQueue.getCurrentEvent() != null;
 }