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


Java方法javax.swing.AbstractButton.getModel代码示例

以下是Java方法javax.swing.AbstractButton.getModel的代码示例。如果您正苦于以下问题:Java AbstractButton.getModel方法的具体用法?Java AbstractButton.getModel怎么用?Java AbstractButton.getModel使用的例子?那么恭喜您, 这里整理的方法代码示例例程将为您提供帮助。您也可以进一步了解该方法所在javax.swing.AbstractButton的用法示例。

本文一共展示了AbstractButton.getModel的6个开源代码实例,这些例子默认根据受欢迎程度排序。您可以为喜欢的代码打CALL点赞,您的评价将有助于我们的系统推荐出更棒的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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源:FlatterButtonUI.java



注:本文示例均筛选自Github等开源项目,代码版权请参考对应项目的License;未经允许,请勿转载。