Java Code Examples for javax.swing.JComponent.getInsets()

The following are Jave code examples for showing how to use getInsets() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: NimbusViewTabDisplayerUI.java   View Source Code Vote up 5 votes
@Override
public Dimension getPreferredSize(JComponent c) {
    FontMetrics fm = getTxtFontMetrics();
    int height = fm == null ?
            19 : fm.getAscent() + 2 * fm.getDescent() + 5;
    Insets insets = c.getInsets();
    prefSize.height = height + insets.bottom + insets.top;
    return prefSize;
}
 
Example 2
Project: incubator-netbeans   File: AquaViewTabDisplayerUI.java   View Source Code Vote up 5 votes
@Override
public Dimension getPreferredSize(JComponent c) {
    FontMetrics fm = getTxtFontMetrics();
    int height = fm == null ?
            21 : fm.getAscent() + 2 * fm.getDescent() + 3;
    height += 1; //align with editor tabs
    Insets insets = c.getInsets();
    prefSize.height = height + insets.bottom + insets.top;
    return prefSize;
}
 
Example 3
Project: incubator-netbeans   File: WinClassicViewTabDisplayerUI.java   View Source Code Vote up 5 votes
@Override
public Dimension getPreferredSize(JComponent c) {
    FontMetrics fm = getTxtFontMetrics();
    int height = fm == null ?
            19 : fm.getAscent() + 2 * fm.getDescent() + 2;
    Insets insets = c.getInsets();
    prefSize.height = height + insets.bottom + insets.top;
    return prefSize;
}
 
Example 4
Project: incubator-netbeans   File: GtkViewTabDisplayerUI.java   View Source Code Vote up 5 votes
public Dimension getPreferredSize(JComponent c) {
    FontMetrics fm = getTxtFontMetrics();
    int height = fm == null ?
            19 : fm.getAscent() + 2 * fm.getDescent() + 5;
    Insets insets = c.getInsets();
    prefSize.height = height + insets.bottom + insets.top;
    return prefSize;
}
 
Example 5
Project: incubator-netbeans   File: MetalViewTabDisplayerUI.java   View Source Code Vote up 5 votes
@Override
public Dimension getPreferredSize(JComponent c) {
    FontMetrics fm = getTxtFontMetrics();
    int height = fm == null ?
            21 : fm.getAscent() + 2 * fm.getDescent() + 4;
    Insets insets = c.getInsets();
    prefSize.height = height + insets.bottom + insets.top;
    return prefSize;
}
 
Example 6
Project: incubator-netbeans   File: AbstractWinViewTabDisplayerUI.java   View Source Code Vote up 5 votes
@Override
public Dimension getPreferredSize(JComponent c) {
    FontMetrics fm = getTxtFontMetrics();
    int height = fm == null ?
            17 : fm.getAscent() + 2 * fm.getDescent() + 3;
    Insets insets = c.getInsets();
    prefSize.height = height + insets.bottom + insets.top;
    return prefSize;
}
 
Example 7
Project: Moenagade   File: LayoutStyle.java   View Source Code Vote up 5 votes
/**
 * Returns the amount to indent the specified component if it's
 * a JCheckBox or JRadioButton.  If the component is not a JCheckBox or
 * JRadioButton, 0 will be returned.
 */
int getButtonChildIndent(JComponent c, int position) {
    if ((c instanceof JRadioButton) || (c instanceof JCheckBox)) {
        AbstractButton button = (AbstractButton)c;
        Insets insets = c.getInsets();
        Icon icon = getIcon(button);
        int gap = button.getIconTextGap();
        if (isLeftAligned(button, position)) {
            return insets.left + icon.getIconWidth() + gap;
        } else if (isRightAligned(button, position)) {
            return insets.right + icon.getIconWidth() + gap;
        }
    }
    return 0;
}
 
Example 8
Project: OpenJSharp   File: MotifScrollBarUI.java   View Source Code Vote up 5 votes
public Dimension getPreferredSize(JComponent c) {
    Insets insets = c.getInsets();
    int dx = insets.left + insets.right;
    int dy = insets.top + insets.bottom;
    return (scrollbar.getOrientation() == JScrollBar.VERTICAL)
        ? new Dimension(dx + 11, dy + 33)
        : new Dimension(dx + 33, dy + 11);
}
 
Example 9
Project: jdk8u-jdk   File: MotifScrollBarUI.java   View Source Code Vote up 5 votes
public Dimension getPreferredSize(JComponent c) {
    Insets insets = c.getInsets();
    int dx = insets.left + insets.right;
    int dy = insets.top + insets.bottom;
    return (scrollbar.getOrientation() == JScrollBar.VERTICAL)
        ? new Dimension(dx + 11, dy + 33)
        : new Dimension(dx + 33, dy + 11);
}
 
Example 10
Project: jdk8u-jdk   File: InsetsEncapsulation.java   View Source Code Vote up 5 votes
void test(final JComponent component) {
    final Insets p = component.getInsets();
    p.top += 3;
    if (p.equals(component.getInsets())) {
        throw new RuntimeException("Insets altered by altering Insets!");
    }
}
 
Example 11
Project: openjdk-jdk10   File: MotifScrollBarUI.java   View Source Code Vote up 5 votes
public Dimension getPreferredSize(JComponent c) {
    Insets insets = c.getInsets();
    int dx = insets.left + insets.right;
    int dy = insets.top + insets.bottom;
    return (scrollbar.getOrientation() == JScrollBar.VERTICAL)
        ? new Dimension(dx + 11, dy + 33)
        : new Dimension(dx + 33, dy + 11);
}
 
Example 12
Project: openjdk-jdk10   File: InsetsEncapsulation.java   View Source Code Vote up 5 votes
void test(final JComponent component) {
    final Insets p = component.getInsets();
    p.top += 3;
    if (p.equals(component.getInsets())) {
        throw new RuntimeException("Insets altered by altering Insets!");
    }
}
 
Example 13
Project: rapidminer   File: ToggleButtonUI.java   View Source Code Vote up 4 votes
@Override
public void paint(Graphics g, JComponent c) {
	AbstractButton b = (AbstractButton) c;

	Dimension size = b.getSize();
	FontMetrics fm = g.getFontMetrics();

	Insets i = c.getInsets();

	Rectangle viewRect = new Rectangle(size);

	viewRect.x += i.left;
	viewRect.y += i.top;
	viewRect.width -= i.right + viewRect.x;
	viewRect.height -= i.bottom + viewRect.y;

	Rectangle iconRect = new Rectangle();
	Rectangle textRect = new Rectangle();

	Font f = c.getFont();
	g.setFont(f);

	String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), b.getIcon(), b.getVerticalAlignment(),
			b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect,
			textRect, b.getText() == null ? 0 : b.getIconTextGap());

	g.setColor(b.getBackground());

	if (b.isContentAreaFilled()) {
		if (RapidLookTools.isToolbarButton(b)) {
			RapidLookTools.drawToolbarButton(g, b);
		} else {
			RapidLookTools.drawButton(b, g, RapidLookTools.createShapeForButton(b));
		}
	}

	if (b.getIcon() != null) {
		paintIcon(g, b, iconRect);
	}

	if (text != null && !text.equals("")) {
		View v = (View) c.getClientProperty(BasicHTML.propertyKey);
		if (v != null) {
			v.paint(g, textRect);
		} else {
			paintText(g, b, textRect, text);
		}
	}

	if (b.isFocusPainted() && b.hasFocus()) {
		paintFocus(g, b, viewRect, textRect, iconRect);
	}

	if (!RapidLookTools.isToolbarButton(b)) {
		if (b.isBorderPainted()) {
			RapidLookTools.drawButtonBorder(b, g, RapidLookTools.createBorderShapeForButton(b));
		}
	}
}