@Override
  public void paint(Graphics g, JComponent c) {
    Graphics2D g2 = (Graphics2D) g;
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();
    initShape(b);
    // ContentArea
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    if (model.isArmed()) {
      g2.setColor(ac);
      g2.fill(shape);
    } else if (b.isRolloverEnabled() && model.isRollover()) {
      paintFocusAndRollover(g2, c, rc);
    } else if (b.hasFocus()) {
      paintFocusAndRollover(g2, c, fc);
    } else {
      g2.setColor(c.getBackground());
      g2.fill(shape);
    }
    // Border
    g2.setPaint(c.getForeground());
    g2.draw(shape);

    g2.setColor(c.getBackground());
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    super.paint(g2, c);
  }
Exemplo n.º 2
0
 /* (non-Javadoc)
  * @see javax.swing.plaf.basic.BasicButtonUI#paint(java.awt.Graphics, javax.swing.JComponent)
  */
 public void paint(Graphics g, JComponent c) {
   //		if (NLXPStyle.getXP() != null)
   {
     paintXPButtonBackground(nomalColor, g, c);
   }
   super.paint(g, c);
 }
Exemplo n.º 3
0
 @Override
 public void installUI(JComponent component) {
   super.installUI(component);
   JButton button = (JButton) component;
   button.setSize(new Dimension(17, 16));
   button.setOpaque(false);
   button.setBorderPainted(false);
 }
 @Override
 protected void installDefaults(AbstractButton b) {
   super.installDefaults(b);
   b.setContentAreaFilled(false);
   b.setOpaque(false);
   b.setBackground(new Color(250, 250, 250));
   initShape(b);
 }
Exemplo n.º 5
0
  public void installUI(JComponent c) {
    super.installUI(c);
    c.setFocusable(false);
    AlgebraTheme theme = AlgebraTheme.getInstance();

    c.setBackground(theme.getHighlightPaper());
    c.setForeground(theme.getHighlightInk());
  }
Exemplo n.º 6
0
 @Override
 public void update(Graphics g, JComponent c) {
   super.update(g, c);
   if (((JButton) c).isDefaultButton() && !SystemInfo.isMac) {
     if (!c.getFont().isBold()) {
       c.setFont(c.getFont().deriveFont(Font.BOLD));
     }
   }
 }
  @Override
  protected void installDefaults(AbstractButton b) {
    super.installDefaults(b);

    String pp = getPropertyPrefix();
    // b.setOpaque(QuaquaManager.getBoolean(pp+"opaque"));
    QuaquaUtilities.installProperty(b, "opaque", UIManager.get(pp + "opaque"));
    b.setRequestFocusEnabled(UIManager.getBoolean(pp + "requestFocusEnabled"));
    b.setFocusable(UIManager.getBoolean(pp + "focusable"));
  }
 //    public void
 public void installDefaults(AbstractButton b) {
   super.installDefaults(b);
   Insets insets = UIManager.getInsets("CollapsiblePaneHeader.margin");
   b.setBorder(
       null); // aqua does this. perhaps other too. this happens early enough that it should not
              // interfere with borders set in user code
   b.setBorder(
       BorderFactory.createEmptyBorder(
           insets.top, insets.left, insets.bottom, insets.right)); // cant get margins to work!
   b.setVerticalAlignment(SwingConstants.BOTTOM);
   b.setHorizontalAlignment(SwingConstants.LEFT);
   //    	b.setMargin(UIManager.getInsets("CollapsiblePaneHeader.margin"));
 }
  public void paintSquare(Graphics g, JComponent c) {
    AbstractButton button = (AbstractButton) c;
    button.getInsets();
    float strokeSize =
        UIManager.getInt(
            "CollapsiblePaneHeader.borderSize"); // KorsakowLookAndFeel.BORDER_STROKE_SIZE;
    int width = c.getWidth();
    width -= 1; // rounded rect gets clipped slightly
    int height = c.getHeight();

    Rectangle bounds = c.getBounds();
    Graphics2D g2 = (Graphics2D) g;

    // background
    // background comes after to cover the crossign lines of the two border rects
    GradientPaint paint =
        new GradientPaint(
            0,
            0,
            UIManager.getColor("CollapsiblePaneHeader.background"),
            0,
            height,
            UIManager.getColor("CollapsiblePaneHeader.background2"),
            false);
    boolean isOver = button.getMousePosition(true) != null;
    if (isOver)
      paint =
          new GradientPaint(
              0,
              0,
              UIManager.getColor("CollapsiblePaneHeader.activeBackground"),
              0,
              height,
              UIManager.getColor("CollapsiblePaneHeader.activeBackground2"),
              false);
    ;
    g2.setPaint(paint);
    g2.fill(bounds);

    // border
    g2.setStroke(new BasicStroke(strokeSize));
    g2.setColor(UIManager.getColor("CollapsiblePaneHeader.border"));
    g2.draw(bounds);

    super.paint(g2, c);
  }
Exemplo n.º 10
0
  public void paint(Graphics g, JComponent c) {
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();

    if (!model.isEnabled()) {
      if (!isDisabled) {
        changeToDisabledColors(c);
      }
    } else if (model.isRollover() || isMouseOver(b)) {
      if (!isRollover) {
        changeToRolloverColors(c);
      }
    } else if (isDisabled || isRollover) {
      changeToOriginalColors(c);
    }
    super.paint(g, c);
  }
Exemplo n.º 11
0
  /* (non-Javadoc)
   * @see javax.swing.plaf.basic.BasicButtonUI#installDefaults(javax.swing.AbstractButton)
   */
  protected void installDefaults(AbstractButton b) {
    super.installDefaults(b);
    b.setOpaque(false);

    if (!defaults_initialized) {
      String pp = getPropertyPrefix();
      dashedRectGapX = UIManager.getInt(pp + "dashedRectGapX");
      dashedRectGapY = UIManager.getInt(pp + "dashedRectGapY");
      dashedRectGapWidth = UIManager.getInt(pp + "dashedRectGapWidth");
      dashedRectGapHeight = UIManager.getInt(pp + "dashedRectGapHeight");
      focusColor = UIManager.getColor(pp + "focus");
      defaults_initialized = true;
    }

    //		BEXPStyle xp = BEXPStyle.getXP();
    //		if (xp != null)
    {
      b.setBorder(
          new XPEmptyBorder(new Insets(3, 3, 3, 3))); // xp.getBorder(b, getXPButtonType(b)));
      LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
    }
  }
Exemplo n.º 12
0
 /**
  * If necessary paints the background of the component, then invokes <code>paint</code>.
  *
  * @param g Graphics to paint to
  * @param c JComponent painting on
  * @throws NullPointerException if <code>g</code> or <code>c</code> is null
  * @see javax.swing.plaf.ComponentUI#update
  * @see javax.swing.plaf.ComponentUI#paint
  * @since 1.5
  */
 public void update(Graphics g, JComponent c) {
   AbstractButton button = (AbstractButton) c;
   if ((c.getBackground() instanceof UIResource)
       && button.isContentAreaFilled()
       && c.isEnabled()) {
     ButtonModel model = button.getModel();
     if (!MetalUtils.isToolBarButton(c)) {
       if (!model.isArmed()
           && !model.isPressed()
           && MetalUtils.drawGradient(
               c, g, "Button.gradient", 0, 0, c.getWidth(), c.getHeight(), true)) {
         paint(g, c);
         return;
       }
     } else if (model.isRollover()
         && MetalUtils.drawGradient(
             c, g, "Button.gradient", 0, 0, c.getWidth(), c.getHeight(), true)) {
       paint(g, c);
       return;
     }
   }
   super.update(g, c);
 }
  @Override
  public void paint(Graphics g, JComponent c) {

    String style = (String) c.getClientProperty("Quaqua.Button.style");
    if (style != null && style.equals("help")) {
      Insets insets = c.getInsets();
      UIManager.getIcon("Button.helpIcon").paintIcon(c, g, insets.left, insets.top);
      return;
    }

    Object oldHints = QuaquaUtilities.beginGraphics((Graphics2D) g);
    if (((AbstractButton) c).isBorderPainted()) {
      Border b = c.getBorder();
      if (b != null && b instanceof BackgroundBorder) {
        ((BackgroundBorder) b)
            .getBackgroundBorder()
            .paintBorder(c, g, 0, 0, c.getWidth(), c.getHeight());
      }
    }
    super.paint(g, c);
    QuaquaUtilities.endGraphics((Graphics2D) g, oldHints);
    Debug.paint(g, c, this);
  }
Exemplo n.º 14
0
 @Override
 public void paint(Graphics g, JComponent c) {
   final Border border = c.getBorder();
   final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
   final boolean square = isSquare(c);
   if (c.isEnabled() && border != null) {
     final Insets ins = border.getBorderInsets(c);
     final int yOff = (ins.top + ins.bottom) / 4;
     if (!square) {
       if (((JButton) c).isDefaultButton()) {
         ((Graphics2D) g)
             .setPaint(
                 UIUtil.getGradientPaint(
                     0,
                     0,
                     getSelectedButtonColor1(),
                     0,
                     c.getHeight(),
                     getSelectedButtonColor2()));
       } else {
         ((Graphics2D) g)
             .setPaint(
                 UIUtil.getGradientPaint(
                     0, 0, getButtonColor1(), 0, c.getHeight(), getButtonColor2()));
       }
     }
     g.fillRoundRect(
         square ? 2 : 4,
         yOff,
         c.getWidth() - 2 * 4,
         c.getHeight() - 2 * yOff,
         square ? 3 : 5,
         square ? 3 : 5);
   }
   config.restore();
   super.paint(g, c);
 }
Exemplo n.º 15
0
 public void uninstallDefaults(AbstractButton b) {
   super.uninstallDefaults(b);
 }
Exemplo n.º 16
0
 /* (non-Javadoc)
  * @see javax.swing.plaf.basic.BasicButtonUI#uninstallDefaults(javax.swing.AbstractButton)
  */
 protected void uninstallDefaults(AbstractButton b) {
   super.uninstallDefaults(b);
   defaults_initialized = false;
 }
Exemplo n.º 17
0
 protected void installListeners(AbstractButton b) {
   super.installListeners(b);
   b.addMouseListener(new RolloverListener(b));
   b.addMouseMotionListener(new RolloverListener(b));
 }
Exemplo n.º 18
0
 /** {@inheritDoc} */
 @Override
 protected void uninstallListeners(AbstractButton b) {
   super.uninstallListeners(b);
   b.removePropertyChangeListener(this);
 }
Exemplo n.º 19
0
 /** {@inheritDoc} */
 @Override
 protected void installListeners(AbstractButton b) {
   super.installListeners(b);
   b.addPropertyChangeListener(this);
 }
 public void installUI(JComponent c) {
   super.installUI(c);
   c.setOpaque(false);
   ((AbstractButton) c).setRolloverEnabled(true);
 }
  public void paintRounded(Graphics g, JComponent c) {
    AbstractButton button = (AbstractButton) c;
    button.getInsets();
    int arcWidth =
        UIManager.getInt(
            "CollapsiblePaneHeader.roundedCornerSize"); // KorsakowLookAndFeel.ROUNDED_CORNER_SIZE;
    int arcHeight =
        UIManager.getInt(
            "CollapsiblePaneHeader.roundedCornerSize"); // KorsakowLookAndFeel.ROUNDED_CORNER_SIZE;
    float strokeSize =
        UIManager.getInt(
            "CollapsiblePaneHeader.borderSize"); // KorsakowLookAndFeel.BORDER_STROKE_SIZE;
    int width = c.getWidth();
    width -= 1; // rounded rect gets clipped slightly
    int height = c.getHeight();

    Rectangle bounds = c.getBounds();
    Graphics2D g2 = (Graphics2D) g;

    RoundRectangle2D.Float borderTopRect =
        new RoundRectangle2D.Float(
            strokeSize / 2,
            strokeSize / 2,
            width - strokeSize,
            height - strokeSize,
            arcWidth,
            arcHeight);
    Rectangle2D.Float borderBottomRect =
        new Rectangle2D.Float(strokeSize / 2, height / 2, width, height / 2);

    // background
    // background comes after to cover the crossign lines of the two border rects
    GradientPaint paint =
        new GradientPaint(
            0,
            0,
            UIManager.getColor("CollapsiblePaneHeader.background"),
            0,
            height,
            UIManager.getColor("CollapsiblePaneHeader.background2"),
            false);
    boolean isOver = button.getMousePosition(true) != null;
    if (isOver)
      paint =
          new GradientPaint(
              0,
              0,
              UIManager.getColor("CollapsiblePaneHeader.activeBackground"),
              0,
              height,
              UIManager.getColor("CollapsiblePaneHeader.activeBackground2"),
              false);
    ;
    g2.setPaint(paint);
    g2.fill(borderTopRect);
    g2.fill(borderBottomRect);

    // border
    g2.setStroke(new BasicStroke(strokeSize));
    g2.setColor(UIManager.getColor("CollapsiblePaneHeader.borderColor"));
    //    	g2.setColor(Color.red);
    KorsakowLafUtil.drawTopRoundedRect(g2, 0, 0, width, height, arcWidth, arcHeight);
    //    	g2.drawArc((int)(borderTopRect.x), (int)(borderTopRect.y), arcWidth, arcHeight*2, 90,
    // 90); // top left
    //    	g2.drawArc((int)(borderTopRect.x+borderTopRect.width-arcWidth), (int)(borderTopRect.y),
    // arcWidth, arcHeight, 0, 90); // top right
    //    	g2.drawLine((int)(borderTopRect.x+arcWidth/2), (int)(borderTopRect.y),
    // (int)(borderTopRect.width-arcWidth/2), (int)borderTopRect.y); // top
    //    	g2.drawLine((int)(borderTopRect.x), (int)(borderTopRect.y+arcHeight/2),
    // (int)(borderTopRect.x), (int)(borderBottomRect.y+borderBottomRect.height)); // left
    //    	g2.drawLine((int)(borderTopRect.x+borderTopRect.width),
    // (int)(borderTopRect.y+arcHeight/2), (int)(borderTopRect.x+borderTopRect.width),
    // (int)(borderBottomRect.y+borderBottomRect.height)); // right
    //    	g2.drawLine((int)(borderTopRect.x), (int)(borderBottomRect.y+borderBottomRect.height-1),
    // (int)(borderTopRect.x + borderTopRect.width),
    // (int)(borderBottomRect.y+borderBottomRect.height-1)); // bottom
    //    	g2.draw(borderTopRect);
    //    	g2.draw(borderBottomRect);

    super.paint(g2, c);
  }
 /**
  * Paints the icon for the toggle button. This delegates to {@link
  * BasicButtonUI#paintIcon(Graphics, JComponent, Rectangle)}.
  *
  * @param g the graphics context
  * @param b the button to paint the icon for
  * @param iconRect the area allocated for the icon
  */
 protected void paintIcon(Graphics g, AbstractButton b, Rectangle iconRect) {
   super.paintIcon(g, b, iconRect);
 }