Exemplo n.º 1
0
  public void paintComponent(Graphics g) {
    if (m.isPressed()) {
      t = colorCount - 1;
      g.setColor(pressed[t]);
      g.fillRect(0, 0, getSize().width - 1, getSize().height - 1);
      g.setColor(border[t]);

    } else {
      g.setColor(rollOver[t]);
      g.fillRect(0, 0, getSize().width - 1, getSize().height - 1);
      g.setColor(border[t]);
      if (m.isRollover()) {
        if (t < colorCount - 1 && !fadeIn.isRunning()) {
          fadeOut.stop();
          fadeIn.start();
        }
      } else {
        if (t > 0 && !fadeOut.isRunning()) {
          fadeIn.stop();
          fadeOut.start();
        }
      }
    }

    super.paintComponent(g);
  }
Exemplo n.º 2
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);
  }
  // Paint the round background and label.
  protected void paintComponent(Graphics g) {
    if (getModel().isArmed()) {
      // You might want to make the highlight color
      // a property of the RoundButton class.
      g.setColor(Color.lightGray);
    } else {
      g.setColor(getBackground());
    }
    g.fillOval(0, 0, getSize().width - 1, getSize().height - 1);

    // This call will paint the label and the
    // focus rectangle.
    super.paintComponent(g);
  }
Exemplo n.º 4
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();
 }
    private void doPaint(Graphics g) {
      GraphicsUtil.setupAntialiasing(g);

      final boolean isEmpty = getIcon() == null && StringUtil.isEmpty(getText());
      final Dimension size = getSize();
      if (isSmallVariant()) {
        final Graphics2D g2 = (Graphics2D) g;
        g2.setColor(UIUtil.getControlColor());
        final int w = getWidth();
        final int h = getHeight();
        if (getModel().isArmed() && getModel().isPressed()) {
          g2.setPaint(
              new GradientPaint(
                  0,
                  0,
                  UIUtil.getControlColor(),
                  0,
                  h,
                  ColorUtil.shift(UIUtil.getControlColor(), 0.8)));
        } else {
          g2.setPaint(
              new GradientPaint(
                  0,
                  0,
                  ColorUtil.shift(UIUtil.getControlColor(), 1.1),
                  0,
                  h,
                  ColorUtil.shift(UIUtil.getControlColor(), 0.9)));
        }
        g2.fillRect(2, 0, w - 2, h);
        GraphicsUtil.setupAntialiasing(g2);
        if (!myMouseInside) {
          g2.setPaint(
              new GradientPaint(
                  0, 0, UIUtil.getBorderColor(), 0, h, UIUtil.getBorderColor().darker()));
          // g2.setColor(UIUtil.getBorderColor());
        } else {
          g2.setPaint(
              new GradientPaint(
                  0,
                  0,
                  UIUtil.getBorderColor().darker(),
                  0,
                  h,
                  UIUtil.getBorderColor().darker().darker()));
        }
        g2.drawRect(2, 0, w - 3, h - 1);
        final Icon icon = getIcon();
        int x = 7;
        if (icon != null) {
          icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2);
          x += icon.getIconWidth() + 3;
        }
        if (!StringUtil.isEmpty(getText())) {
          final Font font = getFont();
          g2.setFont(font);
          g2.setColor(UIManager.getColor("Panel.foreground"));
          g2.drawString(getText(), x, (size.height + font.getSize()) / 2 - 1);
        }
      } else {
        super.paintComponent(g);
      }
      final Insets insets = super.getInsets();
      final Icon icon = isEnabled() ? ARROW_ICON : DISABLED_ARROW_ICON;
      final int x;
      if (isEmpty) {
        x = (size.width - icon.getIconWidth()) / 2;
      } else {
        if (isSmallVariant()) {
          x = size.width - icon.getIconWidth() - insets.right + 1;
        } else {
          x =
              size.width
                  - icon.getIconWidth()
                  - insets.right
                  + (UIUtil.isUnderNimbusLookAndFeel() ? -3 : 2);
        }
      }
      if (UIUtil.isUnderDarcula()) {
        g.setXORMode(new Color(208, 188, 159));
      }
      icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2);
      g.setPaintMode();
    }
Exemplo n.º 6
0
 public void paintComponent(Graphics g) {
   setAntiAliasEnabled(g);
   super.paintComponent(g);
 }
Exemplo n.º 7
0
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    int width = this.getWidth();
    int height = this.getHeight();
    if (!isDisabled) {
      if (this.state == FLAG) {
        g.fillRect(width / 3, height / 5, 2, 3 * height / 5);
        g.setColor(Color.RED);
        g.fillPolygon(
            new int[] {width / 3 + 2, 2 * width / 3, width / 3 + 2},
            new int[] {height / 5, 3 * height / 5, 3 * height / 5},
            3);
      }
    } else {
      switch (state) {
        case MINE: // draw mine in the button
          this.disableButton();
          if (thisMineClicked) g.setColor(Color.RED);
          else g.setColor(Color.BLACK);
          g.fillOval(width / 2 - 5, height / 2 - 5, 10, 10);
          g.fillRect(width / 2 - 1, height / 5, 3, 3 * height / 5);
          g.fillRect(width / 5, height / 2 - 1, 3 * width / 5, 3);
          break;
        case NUMBER:
          switch (num) {
            case 1:
              g.setColor(Color.GREEN);
              g.drawString("1", width / 3, 2 * height / 3);
              break;
            case 2:
              g.setColor(Color.BLUE);
              g.drawString("2", width / 3, 2 * height / 3);
              break;
            case 3:
              g.setColor(Color.RED);
              g.drawString("3", width / 3, 2 * height / 3);
              break;
            case 4:
              g.setColor(Color.DARK_GRAY);
              g.drawString("4", width / 3, 2 * height / 3);
              break;
            case 5:
              g.setColor(Color.MAGENTA);
              g.drawString("5", width / 3, 2 * height / 3);
              break;
            case 6:
              g.setColor(Color.ORANGE);
              g.drawString("6", width / 3, 2 * height / 3);
              break;
            case 7:
              g.setColor(Color.PINK);
              g.drawString("7", width / 3, 2 * height / 3);
              break;
            case 8:
              g.setColor(Color.YELLOW);
              g.drawString("8", width / 3, 2 * height / 3);
              break;
            default:
              break;
          }
        default:
          break;
      }
    }
  }