当前位置: 首页>>代码示例>>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;未经允许,请勿转载。