/** * Paint the component, which is an {@link AbstractButton}, according to its current state. * * @param g The graphics context to paint with * @param c The component to paint the state of */ public void paint(Graphics g, JComponent c) { AbstractButton b = (AbstractButton) c; Rectangle tr = new Rectangle(); Rectangle ir = new Rectangle(); Rectangle vr = new Rectangle(); Font f = c.getFont(); g.setFont(f); if (b.isBorderPainted()) SwingUtilities.calculateInnerArea(b, vr); else vr = SwingUtilities.getLocalBounds(b); String text = SwingUtilities.layoutCompoundLabel( c, g.getFontMetrics(f), b.getText(), currentIcon(b), b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), vr, ir, tr, b.getIconTextGap() + defaultTextShiftOffset); if ((b.getModel().isArmed() && b.getModel().isPressed()) || b.isSelected()) paintButtonPressed(g, b); paintIcon(g, b, ir); if (text != null) paintText(g, b, tr, text); if (b.isFocusOwner() && b.isFocusPainted()) paintFocus(g, b, vr, tr, ir); }
private boolean sizeChanged() { if ((oldComponentInnards == null) || (componentInnards == null)) { return true; } oldComponentInnards.setRect(componentInnards); componentInnards = SwingUtilities.calculateInnerArea(progressBar, componentInnards); return !oldComponentInnards.equals(componentInnards); }
/** * DOCUMENT ME! * * @param context DOCUMENT ME! * @param g DOCUMENT ME! * @param c DOCUMENT ME! */ protected void paintPlaceholderText(SeaGlassContext context, Graphics g, JComponent c) { g.setColor(placeholderColor); g.setFont(c.getFont()); Rectangle innerArea = SwingUtilities.calculateInnerArea(c, null); Rectangle cancelBounds = getCancelButtonBounds(); // FIXME Do better baseline calculation than just subtracting 1. context .getStyle() .getGraphicsUtils(context) .paintText( context, g, getPlaceholderText(g, innerArea.width + cancelBounds.width), innerArea.x, innerArea.y - 1, -1); }