當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。