public void paintComponent(Graphics g) {
    if (getFrame() != null) {
      setState(getFrame().getExtendedState());
    }
    JRootPane rootPane = getRootPane();
    Window window = getWindow();
    boolean leftToRight =
        (window == null)
            ? rootPane.getComponentOrientation().isLeftToRight()
            : window.getComponentOrientation().isLeftToRight();
    boolean isSelected = (window == null) ? true : window.isActive();
    int width = getWidth();
    int height = getHeight();

    Color background;
    Color foreground;
    Color darkShadow;

    if (isSelected) {
      background = UIUtil.getPanelBackground(); // myActiveBackground;
      foreground = myActiveForeground;
      darkShadow = Gray._73; // myActiveShadow;
    } else {
      background = UIUtil.getPanelBackground(); // myInactiveBackground;
      foreground = myInactiveForeground;
      darkShadow = myInactiveShadow;
    }

    g.setColor(background);
    g.fillRect(0, 0, width, height);

    // g.setColor(darkShadow);
    // g.drawLine(0, height - 1, width, height - 1);
    // g.drawLine(0, 0, 0, 0);
    // g.drawLine(width - 1, 0, width - 1, 0);

    int xOffset = leftToRight ? 5 : width - 5;

    if (getWindowDecorationStyle() == JRootPane.FRAME) {
      xOffset += leftToRight ? IMAGE_WIDTH + 5 : -IMAGE_WIDTH - 5;
    }

    String theTitle = getTitle();
    if (theTitle != null) {
      FontMetrics fm = SwingUtilities2.getFontMetrics(rootPane, g);

      g.setColor(foreground);

      int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent();

      Rectangle rect = new Rectangle(0, 0, 0, 0);
      if (myIconifyButton != null && myIconifyButton.getParent() != null) {
        rect = myIconifyButton.getBounds();
      }
      int titleW;

      if (leftToRight) {
        if (rect.x == 0) {
          rect.x = window.getWidth() - window.getInsets().right - 2;
        }
        titleW = rect.x - xOffset - 4;
        theTitle = SwingUtilities2.clipStringIfNecessary(rootPane, fm, theTitle, titleW);
      } else {
        titleW = xOffset - rect.x - rect.width - 4;
        theTitle = SwingUtilities2.clipStringIfNecessary(rootPane, fm, theTitle, titleW);
        xOffset -= SwingUtilities2.stringWidth(rootPane, fm, theTitle);
      }
      int titleLength = SwingUtilities2.stringWidth(rootPane, fm, theTitle);
      if (myIdeMenu == null) {
        SwingUtilities2.drawString(rootPane, g, theTitle, xOffset, yOffset);
        xOffset += leftToRight ? titleLength + 5 : -5;
      }
    }

    int w = width;
    int h = height;
    h--;
    g.setColor(UIManager.getColor("MenuBar.darcula.borderColor"));
    g.drawLine(0, h, w, h);
    h--;
    g.setColor(UIManager.getColor("MenuBar.darcula.borderShadowColor"));
    g.drawLine(0, h, w, h);
  }
Example #2
0
 /*      */ public void paintComponent(Graphics paramGraphics) /*      */ {
   /*  687 */ if (getFrame() != null) {
     /*  688 */ setState(getFrame().getExtendedState());
     /*      */ }
   /*  690 */ JRootPane localJRootPane = getRootPane();
   /*  691 */ Window localWindow = getWindow();
   /*  692 */ boolean bool1 =
       localWindow == null
           ? localJRootPane.getComponentOrientation().isLeftToRight()
           : localWindow.getComponentOrientation().isLeftToRight();
   /*      */
   /*  695 */ boolean bool2 = localWindow == null ? true : localWindow.isActive();
   /*  696 */ int i = getWidth();
   /*  697 */ int j = getHeight();
   /*      */ Color localColor1;
   /*      */ Color localColor2;
   /*      */ Color localColor3;
   /*      */ MetalBumps localMetalBumps;
   /*  705 */ if (bool2) {
     /*  706 */ localColor1 = this.activeBackground;
     /*  707 */ localColor2 = this.activeForeground;
     /*  708 */ localColor3 = this.activeShadow;
     /*  709 */ localMetalBumps = this.activeBumps;
     /*      */ } else {
     /*  711 */ localColor1 = this.inactiveBackground;
     /*  712 */ localColor2 = this.inactiveForeground;
     /*  713 */ localColor3 = this.inactiveShadow;
     /*  714 */ localMetalBumps = this.inactiveBumps;
     /*      */ }
   /*      */
   /*  717 */ paramGraphics.setColor(localColor1);
   /*  718 */ paramGraphics.fillRect(0, 0, i, j);
   /*      */
   /*  720 */ paramGraphics.setColor(localColor3);
   /*  721 */ paramGraphics.drawLine(0, j - 1, i, j - 1);
   /*  722 */ paramGraphics.drawLine(0, 0, 0, 0);
   /*  723 */ paramGraphics.drawLine(i - 1, 0, i - 1, 0);
   /*      */
   /*  725 */ FontMetrics localFontMetrics1 = bool1 ? 5 : i - 5;
   /*      */
   /*  727 */ if (getWindowDecorationStyle() == 1) {
     /*  728 */ localFontMetrics1 += (bool1 ? 21 : -21);
     /*      */ }
   /*      */
   /*  731 */ String str = getTitle();
   /*      */ FontMetrics localFontMetrics2;
   /*      */ int m;
   /*  732 */ if (str != null) {
     /*  733 */ localFontMetrics2 = SwingUtilities2.getFontMetrics(localJRootPane, paramGraphics);
     /*      */
     /*  735 */ paramGraphics.setColor(localColor2);
     /*      */
     /*  737 */ m = (j - localFontMetrics2.getHeight()) / 2 + localFontMetrics2.getAscent();
     /*      */
     /*  739 */ Rectangle localRectangle = new Rectangle(0, 0, 0, 0);
     /*  740 */ if ((this.iconifyButton != null) && (this.iconifyButton.getParent() != null)) {
       /*  741 */ localRectangle = this.iconifyButton.getBounds();
       /*      */ }
     /*      */
     /*  745 */ if (bool1) {
       /*  746 */ if (localRectangle.x == 0) {
         /*  747 */ localRectangle.x =
             (localWindow.getWidth() - localWindow.getInsets().right - 2);
         /*      */ }
       /*  749 */ i1 = localRectangle.x - localFontMetrics1 - 4;
       /*  750 */ str =
           SwingUtilities2.clipStringIfNecessary(localJRootPane, localFontMetrics2, str, i1);
       /*      */ }
     /*      */ else {
       /*  753 */ i1 = localFontMetrics1 - localRectangle.x - localRectangle.width - 4;
       /*  754 */ str =
           SwingUtilities2.clipStringIfNecessary(localJRootPane, localFontMetrics2, str, i1);
       /*      */
       /*  756 */ localFontMetrics1 -=
           SwingUtilities2.stringWidth(localJRootPane, localFontMetrics2, str);
       /*      */ }
     /*      */
     /*  759 */ int i2 = SwingUtilities2.stringWidth(localJRootPane, localFontMetrics2, str);
     /*      */
     /*  761 */ SwingUtilities2.drawString(
         localJRootPane, paramGraphics, str, localFontMetrics1, m);
     /*      */
     /*  763 */ localFontMetrics1 += (bool1 ? i2 + 5 : -5);
     /*      */ }
   /*      */ int k;
   /*  768 */ if (bool1) {
     /*  769 */ m = i - this.buttonsWidth - localFontMetrics1 - 5;
     /*  770 */ localFontMetrics2 = localFontMetrics1;
     /*      */ } else {
     /*  772 */ m = localFontMetrics1 - this.buttonsWidth - 5;
     /*  773 */ k = this.buttonsWidth + 5;
     /*      */ }
   /*  775 */ int n = 3;
   /*  776 */ int i1 = getHeight() - 2 * n;
   /*  777 */ localMetalBumps.setBumpArea(m, i1);
   /*  778 */ localMetalBumps.paintIcon(this, paramGraphics, k, n);
   /*      */ }