本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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) {
}
}
示例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);
}
示例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);
}
}