本文整理汇总了Java中javax.swing.AbstractButton.isEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractButton.isEnabled方法的具体用法?Java AbstractButton.isEnabled怎么用?Java AbstractButton.isEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.AbstractButton
的用法示例。
在下文中一共展示了AbstractButton.isEnabled方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawToolbarButton
import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
* Drasw a button in a toolbar.
*
* @param b
* the button
* @param g
* the graphics instance
*/
public static void drawToolbarButton(Graphics g, AbstractButton b) {
if (!b.isEnabled()) {
return;
}
if (b.getModel().isSelected() && b.isRolloverEnabled() || b.getModel().isPressed() && b.getModel().isArmed()
&& b.isRolloverEnabled()) {
if (b.isContentAreaFilled()) {
drawButton(b, g, createShapeForButton(b));
}
if (b.isBorderPainted()) {
drawButtonBorder(b, g, createBorderShapeForButton(b));
}
} else if (b.getModel().isRollover() && b.isRolloverEnabled()) {
if (b.isBorderPainted()) {
drawButtonBorder(b, g, createBorderShapeForButton(b));
}
}
}
示例2: drawButtonBorder
import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
* Draws the given button border with the specified shape.
*
* @param b
* @param g
* @param shape
*/
public static void drawButtonBorder(AbstractButton b, Graphics g, Shape shape) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (b.isEnabled()) {
if (b.hasFocus()) {
g2.setColor(Colors.BUTTON_BORDER_FOCUS);
} else {
g2.setColor(Colors.BUTTON_BORDER);
}
} else {
g2.setColor(Colors.BUTTON_BORDER_DISABLED);
}
g2.draw(shape);
}
示例3: mouseEntered
import javax.swing.AbstractButton; //导入方法依赖的package包/类
@Override
public void mouseEntered(MouseEvent evt) {
Object src = evt.getSource();
if (src instanceof AbstractButton) {
AbstractButton button = (AbstractButton) evt.getSource();
if (button.isEnabled()) {
button.setContentAreaFilled(true);
button.setBorderPainted(true);
}
}
}
示例4: refresh
import javax.swing.AbstractButton; //导入方法依赖的package包/类
private void refresh(final AbstractButton b) {
b.setBackground(UIUtils.getProfilerResultsBackground());
boolean hovered = Boolean.TRUE.equals(b.getClientProperty(PROP_HOVERED));
boolean filled = b.isEnabled() && (hovered || b.isSelected() || b.isFocusOwner());
b.setOpaque(filled);
b.setContentAreaFilled(filled);
b.repaint();
}
示例5: mouseEntered
import javax.swing.AbstractButton; //导入方法依赖的package包/类
public @Override void mouseEntered(MouseEvent evt) {
Object src = evt.getSource();
if (src instanceof AbstractButton) {
AbstractButton button = (AbstractButton)evt.getSource();
if (button.isEnabled()) {
button.setContentAreaFilled(true);
button.setBorderPainted(true);
}
}
}
示例6: isEnabledAndSelected
import javax.swing.AbstractButton; //导入方法依赖的package包/类
@Override
protected boolean isEnabledAndSelected(AbstractButton button)
{
return button.isEnabled() && button.isSelected();
}
示例7: 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);
}