コード例 #1
0
  /**
   * Paints a customized background.
   *
   * @param g the <tt>Graphics</tt> object through which we paint
   */
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    g = g.create();

    if (!(treeNode instanceof GroupNode) && !isSelected) return;

    AntialiasingManager.activateAntialiasing(g);

    Graphics2D g2 = (Graphics2D) g;

    try {
      internalPaintComponent(g2);
    } finally {
      g.dispose();
    }
  }
コード例 #2
0
  /**
   * Draw the icon at the specified location. Paints this component as an icon.
   *
   * @param c the component which can be used as observer
   * @param g the <tt>Graphics</tt> object used for painting
   * @param x the position on the X coordinate
   * @param y the position on the Y coordinate
   */
  public void paintIcon(Component c, Graphics g, int x, int y) {
    g = g.create();
    try {
      Graphics2D g2 = (Graphics2D) g;
      AntialiasingManager.activateAntialiasing(g2);

      g2.setColor(Color.WHITE);
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
      g2.fillRoundRect(x, y, getIconWidth() - 1, getIconHeight() - 1, 10, 10);
      g2.setColor(Color.DARK_GRAY);
      g2.drawRoundRect(x, y, getIconWidth() - 1, getIconHeight() - 1, 10, 10);

      // Indent component content from the border.
      g2.translate(x + 5, y + 5);

      super.paint(g2);

      g2.translate(x, y);
    } finally {
      g.dispose();
    }
  }