當前位置: 首頁>>代碼示例>>Java>>正文


Java AbstractButton.getIcon方法代碼示例

本文整理匯總了Java中javax.swing.AbstractButton.getIcon方法的典型用法代碼示例。如果您正苦於以下問題:Java AbstractButton.getIcon方法的具體用法?Java AbstractButton.getIcon怎麽用?Java AbstractButton.getIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.AbstractButton的用法示例。


在下文中一共展示了AbstractButton.getIcon方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getIcon

import javax.swing.AbstractButton; //導入方法依賴的package包/類
private Icon getIcon(AbstractButton button) {
    Icon icon = button.getIcon();
    if (icon != null) {
        return icon;
    }
    String key = null;
    if (button instanceof JCheckBox) {
        key = "CheckBox.icon";
    } else if (button instanceof JRadioButton) {
        key = "RadioButton.icon";
    }
    if (key != null) {
        Object oIcon = UIManager.get(key);
        if (oIcon instanceof Icon) {
            return (Icon)oIcon;
        }
    }
    return null;
}
 
開發者ID:fesch,項目名稱:Moenagade,代碼行數:20,代碼來源:LayoutStyle.java

示例2: addButton

import javax.swing.AbstractButton; //導入方法依賴的package包/類
public void addButton(AbstractButton button) {
    Icon icon = button.getIcon();
    Dimension size = new Dimension(icon.getIconWidth() + 6, icon.getIconHeight() + 10);
    button.setPreferredSize(size);
    button.setMargin(new Insets(5, 4, 5, 4));
    toolbar.add(button);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:CustomToolbar.java

示例3: testToggleButtonUnknownIcon

import javax.swing.AbstractButton; //導入方法依賴的package包/類
/**
 * Tests that "unknownIcon" is used if no iconBase
 */
public void testToggleButtonUnknownIcon() throws Exception {
    AbstractButton b = new AlwaysEnabledAction.DefaultIconToggleButton();
    Action action = new TestAction();
    action.putValue("iconBase", null);
    Actions.connect(b, action);
    Icon icon = b.getIcon();
    assertNotNull("null ToggleButton icon", icon);
    Icon expectedIcon = ImageUtilities.loadImageIcon("org/openide/awt/resources/unknown.gif", false); //NOI18N
    assertEquals("unkownIcon not used", expectedIcon, icon);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:ActionsTest.java

示例4: installButtonUI

import javax.swing.AbstractButton; //導入方法依賴的package包/類
@Override
public void installButtonUI(AbstractButton button) {
	button.setUI(new ButtonUI());
	button.setBorder(null);
	button.setMargin(new Insets(0, 0, 0, 0));
	if ((button.getText() == null || "".equals(button.getText())) && button.getIcon() != null) {
		button.setPreferredSize(new Dimension((int) (button.getIcon().getIconWidth() * 1.45d), (int) (button.getIcon()
				.getIconHeight() * 1.45d)));
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:11,代碼來源:RapidDockingToolbar.java

示例5: paint

import javax.swing.AbstractButton; //導入方法依賴的package包/類
@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));
		}
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:60,代碼來源:ToggleButtonUI.java

示例6: paintIcon

import javax.swing.AbstractButton; //導入方法依賴的package包/類
@Override
protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect)
{
	AbstractButton b = (AbstractButton) c;
	ButtonModel model = b.getModel();
	Icon icon = b.getIcon();
	Icon tmpIcon = null;

	if( icon == null )
	{
		return;
	}

	if( !model.isEnabled() )
	{
		if( model.isSelected() )
		{
			tmpIcon = b.getDisabledSelectedIcon();
		}
		else
		{
			tmpIcon = b.getDisabledIcon();
		}
	}
	else if( model.isPressed() && model.isArmed() )
	{
		tmpIcon = b.getPressedIcon();
		if( tmpIcon != null )
		{
			// revert back to 0 offset
			clearTextShiftOffset();
		}
	}
	else if( b.isRolloverEnabled() && model.isRollover() )
	{
		if( model.isSelected() )
		{
			tmpIcon = b.getRolloverSelectedIcon();
		}
		else
		{
			tmpIcon = b.getRolloverIcon();
		}
	}
	else if( model.isSelected() )
	{
		tmpIcon = b.getSelectedIcon();
	}

	if( tmpIcon != null )
	{
		icon = tmpIcon;
	}

	if( model.isPressed() && model.isArmed() )
	{
		icon.paintIcon(c, g, iconRect.x + getTextShiftOffset(), iconRect.y + getTextShiftOffset());
	}
	else
	{
		icon.paintIcon(c, g, iconRect.x, iconRect.y);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:64,代碼來源:FlatterButtonUI.java


注:本文中的javax.swing.AbstractButton.getIcon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。