当前位置: 首页>>代码示例>>Java>>正文


Java AbstractButton.getModel方法代码示例

本文整理汇总了Java中javax.swing.AbstractButton.getModel方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractButton.getModel方法的具体用法?Java AbstractButton.getModel怎么用?Java AbstractButton.getModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.AbstractButton的用法示例。


在下文中一共展示了AbstractButton.getModel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paint

import javax.swing.AbstractButton; //导入方法依赖的package包/类
@Override
public void paint(Graphics g, JComponent c)
{
	AbstractButton b = (AbstractButton) c;
	ButtonModel m = b.getModel();

	b.setBackground(m.isPressed() ? mBackgroundPressed : mBackgroundNormal);
	b.setForeground(m.isEnabled() ? mTextNormal : mTextDisabled);

	super.paint(g, c);
}
 
开发者ID:equella,项目名称:Equella,代码行数:12,代码来源:FlatterButtonUI.java

示例2: getSelected

import javax.swing.AbstractButton; //导入方法依赖的package包/类
public String getSelected()
{
	ButtonModel m = getSelection();
	for (AbstractButton b : buttons)
	{
		if (b.getModel() == m)
		{
			return b.getText();
		}
	}
	return null;
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:13,代码来源:TimeEntry.java

示例3: paint

import javax.swing.AbstractButton; //导入方法依赖的package包/类
public void paint(Graphics g, JComponent c) {
	AbstractButton b = (AbstractButton) c;
	ButtonModel bm = b.getModel();
	if (bm.isRollover()) {
		paintButtonRollOver(g, b);
	} else {
		paintButtonNormal(g, b);
	}
	super.paint(g, c);
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:11,代码来源:XDMToolBarButtonUI.java

示例4: paint

import javax.swing.AbstractButton; //导入方法依赖的package包/类
public void paint(Graphics g, JComponent c) {
	try {
		AbstractButton b = (AbstractButton) c;
		ButtonModel bm = b.getModel();
		if (bm.isRollover()) {
			paintButtonRollOver(g, b);
		} else {
			paintButtonNormal(g, b);
		}
		super.paint(g, c);
	} catch (Exception e) {
	}

}
 
开发者ID:kmarius,项目名称:xdman,代码行数:15,代码来源:XDMButtonUI.java

示例5: paint

import javax.swing.AbstractButton; //导入方法依赖的package包/类
@Override
public synchronized void paint(Graphics g, JComponent c)
{
	AbstractButton b = (AbstractButton) c;
	ButtonModel model = b.getModel();
	Dimension d = b.getSize();

	g.setFont(c.getFont());
	FontMetrics fm = g.getFontMetrics();

	Icon icon = mIconUnchecked;
	if( model.isPressed() && model.isSelected() )
	{
		icon = mIconPressedChecked;
	}
	else if( model.isPressed() && !model.isSelected() )
	{
		icon = mIconPressedUnchecked;
	}
	else if( !model.isPressed() && model.isSelected() )
	{
		icon = mIconChecked;
	}

	int x = 0;
	int y = (d.height - icon.getIconHeight()) / 2;
	icon.paintIcon(c, g, x, y);

	if( b.isEnabled() )
	{
		g.setColor(mTextNormal);
	}
	else
	{
		g.setColor(mTextDisabled);
	}

	String caption = b.getText();
	x = icon.getIconWidth() + mTextIconGap;
	y = (d.height + fm.getAscent()) / 2;
	g.drawString(caption, x, y);
}
 
开发者ID:equella,项目名称:Equella,代码行数:43,代码来源:FlatterCheckBoxUI.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.getModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。