private void setState(int state, boolean updateRegardless) {
    Window wnd = getWindow();

    if (wnd != null && getWindowDecorationStyle() == JRootPane.FRAME) {
      if (myState == state && !updateRegardless) {
        return;
      }
      Frame frame = getFrame();

      if (frame != null) {
        JRootPane rootPane = getRootPane();

        if (((state & Frame.MAXIMIZED_BOTH) != 0)
            && (rootPane.getBorder() == null || (rootPane.getBorder() instanceof UIResource))
            && frame.isShowing()) {
          rootPane.setBorder(null);
        } else if ((state & Frame.MAXIMIZED_BOTH) == 0) {
          // This is a croak, if state becomes bound, this can
          // be nuked.
          rootPaneUI.installBorder(rootPane);
        }
        if (frame.isResizable()) {
          if ((state & Frame.MAXIMIZED_BOTH) != 0) {
            updateToggleButton(myRestoreAction, myMinimizeIcon);
            myMaximizeAction.setEnabled(false);
            myRestoreAction.setEnabled(true);
          } else {
            updateToggleButton(myMaximizeAction, myMaximizeIcon);
            myMaximizeAction.setEnabled(true);
            myRestoreAction.setEnabled(false);
          }
          if (myToggleButton.getParent() == null || myIconifyButton.getParent() == null) {
            add(myToggleButton);
            add(myIconifyButton);
            revalidate();
            repaint();
          }
          myToggleButton.setText(null);
        } else {
          myMaximizeAction.setEnabled(false);
          myRestoreAction.setEnabled(false);
          if (myToggleButton.getParent() != null) {
            remove(myToggleButton);
            revalidate();
            repaint();
          }
        }
      } else {
        // Not contained in a Frame
        myMaximizeAction.setEnabled(false);
        myRestoreAction.setEnabled(false);
        myIconifyAction.setEnabled(false);
        remove(myToggleButton);
        remove(myIconifyButton);
        revalidate();
        repaint();
      }
      myCloseAction.setEnabled(true);
      myState = state;
    }
  }
Example #2
0
 /*      */ private void setState(int paramInt, boolean paramBoolean) /*      */ {
   /*  567 */ Window localWindow = getWindow();
   /*      */
   /*  569 */ if ((localWindow != null) && (getWindowDecorationStyle() == 1)) {
     /*  570 */ if ((this.state == paramInt) && (!paramBoolean)) {
       /*  571 */ return;
       /*      */ }
     /*  573 */ Frame localFrame = getFrame();
     /*      */
     /*  575 */ if (localFrame != null) {
       /*  576 */ JRootPane localJRootPane = getRootPane();
       /*      */
       /*  578 */ if (((paramInt & 0x6) != 0)
           && ((localJRootPane.getBorder() == null)
               || ((localJRootPane.getBorder() instanceof UIResource)))
           && (localFrame.isShowing()))
       /*      */ {
         /*  582 */ localJRootPane.setBorder(null);
         /*      */ }
       /*  584 */ else if ((paramInt & 0x6) == 0)
       /*      */ {
         /*  587 */ this.rootPaneUI.installBorder(localJRootPane);
         /*      */ }
       /*  589 */ if (localFrame.isResizable()) {
         /*  590 */ if ((paramInt & 0x6) != 0) {
           /*  591 */ updateToggleButton(this.restoreAction, this.minimizeIcon);
           /*  592 */ this.maximizeAction.setEnabled(false);
           /*  593 */ this.restoreAction.setEnabled(true);
           /*      */ }
         /*      */ else {
           /*  596 */ updateToggleButton(this.maximizeAction, this.maximizeIcon);
           /*  597 */ this.maximizeAction.setEnabled(true);
           /*  598 */ this.restoreAction.setEnabled(false);
           /*      */ }
         /*  600 */ if ((this.toggleButton.getParent() == null)
             || (this.iconifyButton.getParent() == null))
         /*      */ {
           /*  602 */ add(this.toggleButton);
           /*  603 */ add(this.iconifyButton);
           /*  604 */ revalidate();
           /*  605 */ repaint();
           /*      */ }
         /*  607 */ this.toggleButton.setText(null);
         /*      */ }
       /*      */ else {
         /*  610 */ this.maximizeAction.setEnabled(false);
         /*  611 */ this.restoreAction.setEnabled(false);
         /*  612 */ if (this.toggleButton.getParent() != null) {
           /*  613 */ remove(this.toggleButton);
           /*  614 */ revalidate();
           /*  615 */ repaint();
           /*      */ }
         /*      */ }
       /*      */ }
     /*      */ else
     /*      */ {
       /*  621 */ this.maximizeAction.setEnabled(false);
       /*  622 */ this.restoreAction.setEnabled(false);
       /*  623 */ this.iconifyAction.setEnabled(false);
       /*  624 */ remove(this.toggleButton);
       /*  625 */ remove(this.iconifyButton);
       /*  626 */ revalidate();
       /*  627 */ repaint();
       /*      */ }
     /*  629 */ this.closeAction.setEnabled(true);
     /*  630 */ this.state = paramInt;
     /*      */ }
   /*      */ }