Ejemplo n.º 1
0
  public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D) g.create();
    g2d.setStroke(new BasicStroke(1.0f));

    if (isOpaque()) {
      g2d.setColor(getBackground());
      g2d.fillRect(0, 0, getWidth(), getHeight());
    }

    g2d.setColor(Color.black);
    g2d.drawLine(0, frameHeight / 2, frameWidth, frameHeight / 2);
    g2d.drawLine(frameWidth / 2, 0, frameWidth / 2, frameHeight);

    for (int i = unityX; i < frameWidth / 2; i += unityX) {
      g2d.drawLine(
          frameWidth / 2 + i, frameHeight / 2 - 3, frameWidth / 2 + i, frameHeight / 2 + 3);
      g2d.drawLine(
          frameWidth / 2 - i, frameHeight / 2 - 3, frameWidth / 2 - i, frameHeight / 2 + 3);
    }

    for (int i = unityY; i < frameHeight / 2; i += unityY) {
      g2d.drawLine(
          frameWidth / 2 - 3, frameHeight / 2 + i, frameWidth / 2 + 3, frameHeight / 2 + i);
      g2d.drawLine(
          frameWidth / 2 - 3, frameHeight / 2 - i, frameWidth / 2 + 3, frameHeight / 2 - i);
    }

    g2d.setColor(Color.blue);
    function.drawFunctionToGraphic(g2d, frameWidth, frameHeight, unityX, unityY);

    paintCurrentMethodState(g2d);

    g2d.dispose();
  }
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g.create();
    g2d.setBackground(Color.white);
    int xDim = (int) (getWidth() / 56);
    int yDim = (int) (getHeight() / 66);
    g2d.drawLine(0, (agent[0].length) * yDim, Slope.getWidth() * xDim, (agent[0].length) * yDim);
    g2d.drawRect((Slope.getWidth() - 3) * xDim, 0, 15, Slope.getHeight() * yDim);

    for (int k = 0; k < Slope.getHeight(); k++)
      for (int l = 0; l < Slope.getWidth(); l++) {

        g2d.setColor(new Color(0, 0, 0, 1));
        g2d.drawRect(k * getWidth() / 56, l * getHeight() / 66, 30, 30);
      }

    for (int i = 0; i < agent.length; i++) {
      for (int j = 0; j < agent[0].length; j++) {
        g2d.setColor(Color.blue);
        if (agent[i][j]) {
          //					 g2d.drawString("*", i*getWidth()/56, j*getHeight()/66);
          g2d.drawImage(image, i * getWidth() / 56, j * getHeight() / 66, null);
        }
      }
    }
  }
Ejemplo n.º 3
0
    @Override
    public void paintComponent(Graphics g) {
      Graphics g2 = g.create();

      Dimension d = getSize();
      CPArtwork artwork = controller.getArtwork();
      Object[] layers = artwork.getLayers();

      g2.setColor(new Color(0x606060));
      g2.fillRect(0, 0, d.width, d.height - layers.length * layerH);

      g2.setColor(Color.black);
      g2.translate(0, d.height - layerH);
      for (int i = 0; i < layers.length; i++) {
        drawLayer(g2, (CPLayer) layers[i], i == artwork.getActiveLayerNb());
        g2.translate(0, -layerH);
      }

      if (layerDragReally) {
        g2.translate(0, layers.length * layerH - (d.height - layerH));
        g2.drawRect(0, layerDragY - layerH / 2, d.width, layerH);

        int layerOver = (d.height - layerDragY) / layerH;
        if (layerOver <= layers.length
            && layerOver != layerDragNb
            && layerOver != layerDragNb + 1) {
          g2.fillRect(0, d.height - layerOver * layerH - 2, d.width, 4);
        }
      }
    }
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2 = (Graphics2D) g.create();

    int width = getWidth();
    int height = getHeight();

    // rendering hints
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(
        RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    // formatter
    DecimalFormat format = new DecimalFormat("##.#%");
    // text to display
    String percentage =
        (value == null || Double.parseDouble(value.toString()) == -1)
            ? ""
            : format.format(Double.parseDouble(value.toString()));

    // paint text
    g2.setColor(Color.black);
    g2.setFont(g2.getFont().deriveFont(Font.BOLD));
    FontMetrics fontMetrics = g2.getFontMetrics();
    int textWidth = fontMetrics.stringWidth(percentage);
    int xPos = (width - textWidth) / 2;
    int yPos = height / 2 + fontMetrics.getDescent() + 2;
    g2.drawString(percentage, xPos, yPos);

    g2.dispose();
  }
  /*
   * (non-Javadoc)
   *
   * @seeorg.jvnet.flamingo.common.ui.BasicCommandButtonUI#
   * paintButtonVerticalSeparator(java.awt.Graphics, int)
   */
  @Override
  protected void paintButtonVerticalSeparator(Graphics graphics, Rectangle separatorArea) {
    Graphics2D g2d = (Graphics2D) graphics.create();
    g2d.translate(separatorArea.x, 0);

    SubstanceColorScheme colorScheme =
        SubstanceColorSchemeUtilities.getColorScheme(
            this.commandButton,
            ColorSchemeAssociationKind.SEPARATOR,
            ComponentState.getState(this.commandButton.getActionModel(), this.commandButton));

    float fadeAlpha = this.getSeparatorAlpha();
    g2d.setComposite(AlphaComposite.SrcOver.derive(fadeAlpha));

    SeparatorPainterUtils.paintSeparator(
        this.commandButton,
        g2d,
        colorScheme,
        1,
        this.commandButton.getHeight(),
        JSlider.VERTICAL,
        true,
        4,
        4,
        true);

    g2d.dispose();
  }
Ejemplo n.º 6
0
    public void paintComponent(Graphics g) {
      g.setColor(new Color(96, 96, 96));
      image.paintIcon(this, g, 1, 1);

      FontMetrics fm = g.getFontMetrics();

      String[] args = {jEdit.getVersion()};
      String version = jEdit.getProperty("about.version", args);
      g.drawString(version, (getWidth() - fm.stringWidth(version)) / 2, getHeight() - 5);

      g = g.create((getWidth() - maxWidth) / 2, TOP, maxWidth, getHeight() - TOP - BOTTOM);

      int height = fm.getHeight();
      int firstLine = scrollPosition / height;

      int firstLineOffset = height - scrollPosition % height;
      int lines = (getHeight() - TOP - BOTTOM) / height;

      int y = firstLineOffset;

      for (int i = 0; i <= lines; i++) {
        if (i + firstLine >= 0 && i + firstLine < text.size()) {
          String line = (String) text.get(i + firstLine);
          g.drawString(line, (maxWidth - fm.stringWidth(line)) / 2, y);
        }
        y += fm.getHeight();
      }
    }
  public static void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    g = g.create(x, y, width, height);
    // corners
    TL.paintIcon(c, g, x, y);
    BL.paintIcon(c, g, x, y + height - BL.getIconHeight());
    TR.paintIcon(c, g, x + width - TR.getIconWidth(), y);
    BR.paintIcon(c, g, x + width - BR.getIconWidth(), y + height - BR.getIconHeight());

    // top and bottom lines
    int xOffset = x + TL.getIconWidth();
    int stop = x + width - TR.getIconWidth();
    int top = y;
    int bottom = y + height - B.getIconHeight();
    g.setClip(xOffset, y, width - L.getIconWidth() - R.getIconWidth(), height);
    while (xOffset < stop) {
      T.paintIcon(c, g, xOffset, top);
      B.paintIcon(c, g, xOffset, bottom);
      xOffset += T.getIconWidth();
    }

    // left and right lines
    int left = x;
    int right = x + width - R.getIconWidth();
    int yOffset = y + T.getIconHeight();
    stop = y + height - B.getIconHeight();
    g.setClip(x, yOffset, width, height - T.getIconHeight() - B.getIconHeight());
    while (yOffset < stop) {
      L.paintIcon(c, g, left, yOffset);
      R.paintIcon(c, g, right, yOffset);
      yOffset += L.getIconHeight();
    }
    g.dispose();
  }
Ejemplo n.º 8
0
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    if (drawOverlay) {
      g = g.create();
      AntialiasingManager.activateAntialiasing(g);

      try {
        // Paint a roll over fade out.
        FadeTracker fadeTracker = FadeTracker.getInstance();

        float visibility = 0.0f;
        if (fadeTracker.isTracked(this, FadeKind.ROLLOVER)) {
          visibility = fadeTracker.getFade(this, FadeKind.ROLLOVER);
          visibility /= 4;
        } else visibility = 0.5f;

        // Draw black overlay
        g.setColor(new Color(0.0f, 0.0f, 0.0f, visibility));
        g.fillRoundRect(1, 1, width - 2, height - 2, 10, 10);

        // Draw arrow
        g.setColor(Color.WHITE);

        int[] arrowX = new int[] {width - 17, width - 7, width - 12};
        int[] arrowY = new int[] {height - 12, height - 12, height - 7};
        g.fillPolygon(arrowX, arrowY, arrowX.length);
      } finally {
        g.dispose();
      }
    }
  }
Ejemplo n.º 9
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    int centerX = getWidth() / 2;
    int centerY = getHeight() / 2;

    Graphics2D g2d = (Graphics2D) g.create();

    g2d.translate(centerX, centerY); // Set Graphics2D transform origin to center of panel

    g2d.setColor(fgColor);
    bar.setFrame(-barWidth / 2, -barHeight / 2 + barHeight * barPosition, barWidth, barHeight);
    g2d.fill(bar);
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    for (Spike spike : spikes) {
      if (spike != null) {
        double opacity = 255;
        if (spike.getDirection() == 0) {
          opacity = getWidth() * 0.5 - 70 - spike.getPosition().getX();
        } else {
          opacity = spike.getPosition().getX() + getWidth() * 0.5 - 70;
        }
        g2d.setColor(new Color(0, 0, 0, (int) clamp(opacity * 10, 0, 255)));
        g2d.fill(spike);
      }
    }
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    g2d.setColor(Color.BLACK);
    g2d.draw(barCross);
    g2d.setStroke(new BasicStroke(2));
    g2d.draw(barFrame);
    g2d.dispose();
  }
Ejemplo n.º 10
0
  /**
   * Draws a double headed arrow with arrow heads of a given width and height.
   *
   * @param aG the canvas to draw on;
   * @param aX1 the starting X position of the arrow;
   * @param aY1 the starting Y position of the arrow;
   * @param aX2 the ending X position of the arrow;
   * @param aY2 the ending Y position of the arrow;
   * @param aArrowWidth the total width of the arrow head;
   * @param aArrowHeight the total height of the arrow head.
   */
  public static final void drawDoubleHeadedArrow(
      final Graphics aG,
      final int aX1,
      final int aY1,
      final int aX2,
      final int aY2,
      final int aArrowWidth,
      final int aArrowHeight) {
    final Graphics2D g2d = (Graphics2D) aG.create();

    final int lineWidth = Math.abs(aX2 - aX1);
    final int threshold = (2 * aArrowWidth) + 2;
    try {
      int x1 = aX1;
      int x2 = aX2;

      if (lineWidth > threshold) {
        drawArrowHead(g2d, aX1, aY1, LEFT_FACING, aArrowWidth, aArrowHeight);
        // why x2 needs to be shifted by one pixel is beyond me...
        drawArrowHead(g2d, aX2 + 1, aY2, RIGHT_FACING, aArrowWidth, aArrowHeight);

        x1 += aArrowWidth - 1;
        x2 -= aArrowWidth + 1;
      }

      g2d.drawLine(x1, aY1, x2, aY2);
    } finally {
      g2d.dispose();
    }
  }
    @Override
    public void paintComponent(final Graphics g) {

      Graphics2D g2d = (Graphics2D) g.create();

      Dimension srcSize = image.getSizeForPaint(g2d);
      int wSrc = srcSize.width;
      int hSrc = srcSize.height;

      int wImg = getPreferredSize().width;
      int hImg = getPreferredSize().height;

      int xOffset = (getSize().width - wImg) / 2;

      RenderingHints hints =
          new RenderingHints(
              RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
      g2d.setRenderingHints(hints);

      FSkin.drawImage(
          g2d,
          image,
          xOffset,
          0,
          wImg + xOffset,
          hImg, // Destination
          0,
          0,
          wSrc,
          hSrc); // Source

      g2d.dispose();
    }
  @Override
  protected void paintBackground(Graphics g, JComponent component) {
    getGlassParameters();
    Graphics2D g2d = (Graphics2D) g.create();

    if (getOrientation().isHorizontal()) {
      paintBackground(
          g2d,
          0,
          0,
          component.getWidth(),
          component.getHeight(),
          getOrientation().isHorizontal(),
          component);
    } else {
      paintBackground(
          g2d,
          0,
          0,
          component.getHeight(),
          component.getWidth(),
          getOrientation().isHorizontal(),
          component);
    }

    g2d.dispose();
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.jvnet.flamingo.common.ui.BasicCommandButtonUI#paintButtonBackground
   * (java.awt.Graphics, java.awt.Rectangle)
   */
  @Override
  protected void paintButtonBackground(Graphics graphics, Rectangle toFill) {
    if (SubstanceCoreUtilities.isButtonNeverPainted(this.commandButton)) return;

    ButtonModel actionModel = this.commandButton.getActionModel();
    PopupButtonModel popupModel = ((JCommandButton) this.commandButton).getPopupModel();
    Rectangle actionArea = this.getLayoutInfo().actionClickArea;
    Rectangle popupArea = this.getLayoutInfo().popupClickArea;

    BufferedImage fullAlphaBackground =
        CommandButtonBackgroundDelegate.getCombinedCommandButtonBackground(
            this.commandButton, actionModel, actionArea, popupModel, popupArea);

    // Two special cases here:
    // 1. Button has flat appearance and doesn't show the popup
    // 2. Button is disabled.
    // For both cases, we need to set custom translucency.
    boolean isFlat =
        this.commandButton.isFlat()
            && !((JCommandButton) this.commandButton).getPopupModel().isPopupShowing();
    boolean isSpecial = isFlat || !this.commandButton.isEnabled();
    float extraAlpha = 1.0f;
    if (isSpecial) {
      if (isFlat) {
        float extraActionAlpha = 0.0f;
        for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry :
            getActionTransitionTracker().getModelStateInfo().getStateContributionMap().entrySet()) {
          ComponentState activeState = activeEntry.getKey();
          if (activeState.isDisabled()) continue;
          if (activeState == ComponentState.ENABLED) continue;
          extraActionAlpha += activeEntry.getValue().getContribution();
        }
        float extraPopupAlpha = 0.0f;
        for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry :
            getPopupTransitionTracker().getModelStateInfo().getStateContributionMap().entrySet()) {
          ComponentState activeState = activeEntry.getKey();
          if (activeState.isDisabled()) continue;
          if (activeState == ComponentState.ENABLED) continue;
          extraPopupAlpha += activeEntry.getValue().getContribution();
        }
        extraAlpha = Math.max(extraActionAlpha, extraPopupAlpha);
      } else {
        ComponentState actionAreaState = ComponentState.getState(actionModel, this.commandButton);
        if (actionAreaState.isDisabled()) {
          extraAlpha = SubstanceColorSchemeUtilities.getAlpha(this.commandButton, actionAreaState);
        }
      }
    }
    // System.out.println(extraAlpha);
    extraAlpha = Math.min(1.0f, extraAlpha);
    if (extraAlpha > 0.0f) {
      Graphics2D g2d = (Graphics2D) graphics.create();
      g2d.setComposite(
          LafWidgetUtilities.getAlphaComposite(this.commandButton, extraAlpha, graphics));
      g2d.drawImage(fullAlphaBackground, 0, 0, null);
      g2d.dispose();
    }
  }
Ejemplo n.º 14
0
 /**
  * Paint a background for all groups and a round blue border and background when a cell is
  * selected.
  *
  * @param g the <tt>Graphics</tt> object
  */
 public void paintComponent(Graphics g) {
   Graphics g2 = g.create();
   try {
     internalPaintComponent(g2);
   } finally {
     g2.dispose();
   }
   super.paintComponent(g);
 }
Ejemplo n.º 15
0
 @Override
 public void paintIcon(Component c, Graphics g, int x, int y) {
   Graphics2D g2 = (Graphics2D) g.create();
   g2.translate(x, y);
   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   g2.setPaint(Color.ORANGE);
   g2.fill(star);
   g2.dispose();
 }
Ejemplo n.º 16
0
 @Override
 protected void paintComponent(Graphics g) {
   BufferedImage image = theImage.getImage();
   if (image != null) {
     Graphics2D gg = (Graphics2D) g.create();
     overlay.paint(gg, image, theImage.getImageTransform());
     gg.dispose();
   }
 }
 public void paint(Graphics g) {
   putClientProperty("JTree.lineStyle", "None");
   Graphics g1 = g.create();
   g1.translate(0, -myVisibleRow * getRowHeight());
   super.paint(g1);
   g1.dispose();
   if (myBorder != null) {
     myBorder.paintBorder(this, g, 0, 0, myTreeTable.getWidth(), getRowHeight());
   }
 }
Ejemplo n.º 18
0
 public void paintImage(Graphics g) {
   final Rectangle b = getBounds();
   final Graphics lG = g.create(b.x, b.y, b.width, b.height);
   try {
     lG.setColor(Color.red);
     doPaint(lG);
   } finally {
     lG.dispose();
   }
 }
Ejemplo n.º 19
0
 @Override
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   Graphics2D g2 = (Graphics2D) g.create();
   g2.translate(x, y);
   g2.setPaint(borderSelectionColor);
   g2.drawRect(0, 0, w - 1, h - 1);
   g2.setPaint(getLineColor());
   BasicGraphicsUtils.drawDashedRect(g2, 0, 0, w, h);
   g2.dispose();
 }
 @Override
 protected void paintTabBackground(
     Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) {
   g = g.create();
   try {
     internalPaintTabBackground(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
   } finally {
     g.dispose();
   }
 }
 @Override
 protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g.create();
   int offset = 0;
   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   g2.setRenderingHint(
       RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
   g2.drawString(ptmString.getIterator(), offset, 15);
   g2.dispose();
 }
Ejemplo n.º 22
0
  /**
   * Paint a background for all groups and a round blue border and background when a cell is
   * selected.
   *
   * @param g the <tt>Graphics</tt> object used for painting
   */
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    g = g.create();
    try {
      internalPaintComponent(g);
    } finally {
      g.dispose();
    }
  }
Ejemplo n.º 23
0
  /**
   * Overrides the <code>paintComponent</code> method of <tt>JButton</tt> to paint the button
   * background and icon, and all additional effects of this configurable button.
   *
   * @param g The Graphics object.
   */
  @Override
  protected void paintComponent(Graphics g) {
    Graphics2D g1 = (Graphics2D) g.create();
    try {
      internalPaintComponent(g1);
    } finally {
      g1.dispose();
    }

    super.paintComponent(g);
  }
 private void doPaintStatusText(Graphics g, Rectangle textComponentBounds) {
   myComponent.setBounds(0, 0, textComponentBounds.width, textComponentBounds.height);
   Graphics2D g2 =
       (Graphics2D)
           g.create(
               textComponentBounds.x,
               textComponentBounds.y,
               textComponentBounds.width,
               textComponentBounds.height);
   myComponent.paint(g2);
   g2.dispose();
 }
 public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
   float size = this.stroke.getLineWidth();
   if (size > 0.0f) {
     g = g.create();
     if (g instanceof Graphics2D) {
       Graphics2D g2d = (Graphics2D) g;
       g2d.setStroke(this.stroke);
       g2d.setPaint(color != null ? color : c == null ? null : c.getForeground());
       g2d.draw(new Rectangle2D.Float(x + size / 2, y + size / 2, width - size, height - size));
     }
     g.dispose();
   }
 }
Ejemplo n.º 26
0
  public void paintComponent(Graphics g) {

    if (Principal.fondoBlur) {
      if (isVisible() && blurBuffer != null && listo) {
        Graphics2D g2 = (Graphics2D) g.create();
        g2.setRenderingHint(
            RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g2.drawImage(backBuffer, 0, 0, null);
        g2.setComposite(AlphaComposite.SrcOver.derive(alpha));
        g2.drawImage(blurBuffer, 0, 0, getWidth(), getHeight(), null);
        g2.dispose();
      }
    }
  }
Ejemplo n.º 27
0
    /** @{inheritDoc} */
    @Override
    public void paintComponent(Graphics g) {
      super.paintComponent(g);

      g = g.create();

      try {
        AntialiasingManager.activateAntialiasing(g);

        g.setColor(Color.DARK_GRAY);
        g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 10, 10);
      } finally {
        g.dispose();
      }
    }
 public void setViewportSize(Dimension _size) {
   mViewportSize = new Dimension(_size);
   int w = mViewportSize.width + 2 * INSET;
   int h = mViewportSize.height + 2 * INSET;
   // create an off screen buffer for drawing
   if (mBackBufferGfx != null) {
     mBackBufferGfx.dispose(); // free old one
   }
   mBackBufferImg = createImage(w, h);
   Logger.log("Create off-screen buffer of " + w + "x" + h + " (" + mBackBufferImg + ")");
   mBackBufferGfx = mBackBufferImg.getGraphics();
   // Determine the graphics context for the viewport
   mDrawGfx = mBackBufferGfx.create(INSET, INSET, mViewportSize.width, mViewportSize.height);
   mViewport.setActualSize(mViewportSize);
   Logger.log("Viewport resized");
 }
Ejemplo n.º 29
0
 @Override
 public void paintIcon(Component c, Graphics g, int x, int y) {
   Graphics2D g2 = (Graphics2D) g.create();
   g2.setPaint(Objects.nonNull(c) ? c.getBackground() : Color.WHITE);
   g2.fillRect(x, y, getIconWidth(), getIconHeight());
   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   g2.setColor(ELLIPSE_COLOR);
   g2.translate(x, y);
   int size = list.size();
   for (int i = 0; i < size; i++) {
     float alpha = isRunning ? (i + 1) / (float) size : .5f;
     g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
     g2.fill(list.get(i));
   }
   // g2.translate(-x, -y);
   g2.dispose();
 }
Ejemplo n.º 30
0
 @Override
 protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g.create();
   if (getModel().isPressed()) {
     g2.translate(1, 1);
   }
   g2.setStroke(new BasicStroke(2));
   g2.setColor(Color.BLACK);
   if (getModel().isRollover()) {
     g2.setColor(Color.WHITE);
   }
   int delta = 6;
   g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1);
   g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1);
   g2.dispose();
 }