javax.swing.AbstractButton#getMargin ( )源码实例Demo

下面列出了javax.swing.AbstractButton#getMargin ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: SlidingButtonUI.java
protected void paintBackground(Graphics2D g, AbstractButton b) {
    Dimension size = b.getSize();
    
    Insets insets = b.getInsets();
    Insets margin = b.getMargin();
    if( null == insets || null == margin )
        return;
    g.fillRect(insets.left - margin.left,
        insets.top - margin.top,
    size.width - (insets.left-margin.left) - (insets.right - margin.right),
    size.height - (insets.top-margin.top) - (insets.bottom - margin.bottom));
}
 
源代码2 项目: RipplePower   文件: ButtonUI.java
public Dimension getPreferredSize(JComponent c) {
	AbstractButton b = (AbstractButton) c;
	Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b, b.getIconTextGap());
	Insets margin = b.getMargin();
	d.setSize(d.getWidth() + margin.left + margin.right, d.getHeight() + margin.top + margin.bottom);
	return d;
}
 
源代码3 项目: RipplePower   文件: NavlinkUI.java
public Dimension getPreferredSize(JComponent c) {
	AbstractButton b = (AbstractButton) c;
	Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b, b.getIconTextGap());
	Insets margin = b.getMargin();
	d.setSize(d.getWidth() + margin.left + margin.right, d.getHeight() + margin.top + margin.bottom);
	return d;
}
 
源代码4 项目: pumpernickel   文件: QButtonUI.java
@Override
public Insets getBorderInsets(Component c) {
	JComponent jc = (JComponent) c;
	AbstractButton button = (jc instanceof AbstractButton) ? (AbstractButton) jc
			: null;
	Insets i = new Insets(0, 0, 0, 0);

	boolean isFocusPainted = button == null || button.isFocusPainted();
	if (paintFocus == PaintFocus.OUTSIDE && isFocusPainted) {
		i.top += focusRingSize;
		i.left += focusRingSize;
		i.bottom += focusRingSize;
		i.right += focusRingSize;
	}

	if (buttonFill.getShadowHighlight(new ButtonState.Float(0, 0, 0, 0,
			0)) != null) {
		i.bottom = Math.max(1, i.bottom);
	}

	// 1 pixel for the stroke itself
	i.top++;
	i.left++;
	i.bottom++;
	i.right++;

	int interior = cornerRadius;
	if (paintFocus == PaintFocus.INSIDE && isFocusPainted)
		interior = Math.max(interior, focusRingSize);
	interior = Math.max(interior, 3);

	int interiorSegment = Math.max(interior - 4, 2);

	HorizontalPosition horizontalPosition = getHorizontalPosition(jc);
	switch (horizontalPosition) {
	case ONLY:
		i.left += interior;
		i.right += interior;
		break;
	case LEFT:
		i.left += interior;
		i.right += interiorSegment;
		break;
	case MIDDLE:
		i.left += interiorSegment;
		i.right += interiorSegment;
		break;
	case RIGHT:
		i.left += interiorSegment;
		i.right += interior;
	}

	VerticalPosition verticalPosition = getVerticalPosition(jc);
	switch (verticalPosition) {
	case ONLY:
		i.top += interior;
		i.bottom += interior;
		break;
	case TOP:
		i.top += interior;
		i.bottom += interiorSegment;
		break;
	case MIDDLE:
		i.top += interiorSegment;
		i.bottom += interiorSegment;
		break;
	case BOTTOM:
		i.top += interiorSegment;
		i.bottom += interior;
	}

	// TODO: maybe rethink how we suport margins? Instead of setting it once
	// in installUI, we could update it with the "interior" calculations above
	Insets margin = button == null ? null : button.getMargin();
	if (margin != null) {
		i.top += margin.top;
		i.left += margin.left;
		i.bottom += margin.bottom;
		i.right += margin.right;
	}

	return i;
}
 
源代码5 项目: seaglass   文件: SeaGlassButtonUI.java
/**
 * Update the style of the button.
 *
 * @param b the button.
 */
public void updateStyle(AbstractButton b) {
    SeaGlassContext context  = getContext(b, SynthConstants.ENABLED);
    SynthStyle      oldStyle = style;

    style = SeaGlassLookAndFeel.updateStyle(context, this);
    if (style != oldStyle) {
        if (b.getMargin() == null || (b.getMargin() instanceof UIResource)) {
            Insets margin = (Insets) style.get(context, getPropertyPrefix() + "margin");

            if (margin == null) {
                // Some places assume margins are non-null.
                margin = SeaGlassLookAndFeel.EMPTY_UIRESOURCE_INSETS;
            }

            b.setMargin(margin);
        }

        Object value = style.get(context, getPropertyPrefix() + "iconTextGap");

        if (value != null) {
            LookAndFeel.installProperty(b, "iconTextGap", value);
        }

        value = style.get(context, getPropertyPrefix() + "contentAreaFilled");
        LookAndFeel.installProperty(b, "contentAreaFilled", value != null ? value : Boolean.TRUE);

        value = b.getClientProperty(APPLE_PREFIX + "buttonType");
        if (value != null) {
            if ("segmented".equals(value)) {
                b.setMargin(SeaGlassLookAndFeel.EMPTY_UIRESOURCE_INSETS);
            }
        }

        if (oldStyle != null) {
            uninstallKeyboardActions(b);
            installKeyboardActions(b);
        }
    }

    context.dispose();
}