javax.swing.AbstractButton#isEnabled ( )源码实例Demo

下面列出了javax.swing.AbstractButton#isEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pumpernickel   文件: QButtonUI.java
@Override
protected void paintText(Graphics g, AbstractButton b, Rectangle textRect,
		String text) {
	// this hack helps us render a button in a different enabled state
	// than what it really is:
	ButtonState.Boolean state = (ButtonState.Boolean) b
			.getClientProperty(PROPERTY_BOOLEAN_BUTTON_STATE);
	if (state != null && state.isEnabled() != b.isEnabled()) {
		scratchButton.setText(b.getText());
		scratchButton.setDisplayedMnemonicIndex(b
				.getDisplayedMnemonicIndex());
		scratchButton.setForeground(b.getForeground());
		scratchButton.setFont(b.getFont());
		scratchButton.setBackground(b.getBackground());
		scratchButton.setEnabled(state.isEnabled());
		super.paintText(g, scratchButton, textRect, text);
		return;
	}
	super.paintText(g, b, textRect, text);
}
 
源代码2 项目: rapidminer-studio   文件: RapidLookTools.java
/**
 * 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));
		}
	}
}
 
源代码3 项目: netbeans   文件: TransparentToolBar.java
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();
}
 
源代码4 项目: netbeans   文件: SearchButton.java
@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);
        }
    }
}
 
源代码5 项目: netbeans   文件: NbEditorToolBar.java
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 项目: netbeans   文件: DataViewUI.java
@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);
        }
    }
}
 
源代码7 项目: ccu-historian   文件: FloatingButtonEnabler.java
/**
 * Triggers the drawing of the border when the mouse entered the button area.
 *
 * @param e  the mouse event.
 */
public void mouseEntered(final MouseEvent e) {
    if (e.getSource() instanceof AbstractButton) {
        final AbstractButton button = (AbstractButton) e.getSource();
        if (button.isEnabled()) {
            button.setBorderPainted(true);
        }
    }
}
 
源代码8 项目: orbit-image-analysis   文件: ButtonBorder.java
public void paintBorder(Component c, Graphics g, int x, int y, int width,
  int height) {
  if (c instanceof AbstractButton) {
    AbstractButton b = (AbstractButton)c;
    ButtonModel model = b.getModel();

    boolean isPressed;
    boolean isRollover;
    boolean isEnabled;

    isPressed = model.isPressed() && model.isArmed();
    isRollover = b.isRolloverEnabled() && model.isRollover();
    isEnabled = b.isEnabled();

    if (!isEnabled) {
      paintDisabled(b, g, x, y, width, height);
    } else {
      if (isPressed) {
        paintPressed(b, g, x, y, width, height);
      } else if (isRollover) {
        paintRollover(b, g, x, y, width, height);
      } else {
        paintNormal(b, g, x, y, width, height);
      }
    }
  }
}
 
源代码9 项目: visualvm   文件: TransparentToolBar.java
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();
}
 
源代码10 项目: visualvm   文件: TransparentToolBar.java
private void refresh(final AbstractButton b) {
    b.setBackground(UISupport.getDefaultBackground());
    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();
}
 
源代码11 项目: pumpernickel   文件: DoubleClickListener.java
/**
 * When a double-click is observed a button is clicked.
 * 
 * @param button
 *            when a double-click is observed this button's
 *            <code>doClick()</code> method is invoked if it is enabled.
 */
public DoubleClickListener(final AbstractButton button) {
	this(new Runnable() {
		public void run() {
			if (button.isEnabled())
				button.doClick();
		}
	});
	if (button == null)
		throw new NullPointerException();
}
 
源代码12 项目: rapidminer-studio   文件: RapidLookTools.java
/**
 * 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);

	boolean darkBorder = Boolean.parseBoolean(String.valueOf(b.getClientProperty(RapidLookTools.PROPERTY_BUTTON_DARK_BORDER)));
	if (darkBorder) {
		if (b.isEnabled()) {
			if (b.hasFocus()) {
				g2.setColor(Colors.BUTTON_BORDER_DARK_FOCUS);
			} else {
				g2.setColor(Colors.BUTTON_BORDER_DARK);
			}
		} else {
			g2.setColor(Colors.BUTTON_BORDER_DARK_DISABLED);
		}
	} else {
		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);
}
 
源代码13 项目: stendhal   文件: StyledButtonUI.java
@Override
protected void paintText(Graphics graphics, AbstractButton button,
		Rectangle textRect, String text) {
	if (button.isEnabled()) {
		super.paintText(graphics, button, textRect, text);
	} else {
		int shift = graphics.getFontMetrics().getAscent();

		StyleUtil.paintDisabledText(style, graphics, text, textRect.x, textRect.y + shift);
	}
}
 
源代码14 项目: stendhal   文件: StyledCheckBoxUI.java
@Override
protected void paintText(Graphics graphics, AbstractButton button,
		Rectangle textRect, String text) {
	if (button.isEnabled()) {
		super.paintText(graphics, button, textRect, text);
	} else {
		int shift = graphics.getFontMetrics().getAscent();

		StyleUtil.paintDisabledText(style, graphics, text, textRect.x, textRect.y + shift);
	}
}
 
源代码15 项目: seaglass   文件: SeaGlassButtonUI.java
/**
 * Returns the Icon used in calculating the pref/min/max size.
 *
 * @param  b DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
protected Icon getSizingIcon(AbstractButton b) {
    // NOTE: this is slightly different than BasicButtonUI, where it
    // would just use getIcon, but this should be ok.
    Icon icon = (b.isEnabled() || b.getDisabledIcon() == null) ? b.getIcon() : b.getDisabledIcon();

    if (icon == null) {
        icon = getDefaultIcon(b);
    }

    return icon;
}
 
源代码16 项目: CodenameOne   文件: ButtonBorder.java
public void paintBorder(Component c, Graphics g, int x, int y, int width,
  int height) {
  if (c instanceof AbstractButton) {
    AbstractButton b = (AbstractButton)c;
    ButtonModel model = b.getModel();

    boolean isPressed;
    boolean isRollover;
    boolean isEnabled;

    isPressed = model.isPressed() && model.isArmed();
    isRollover = b.isRolloverEnabled() && model.isRollover();
    isEnabled = b.isEnabled();

    if (!isEnabled) {
      paintDisabled(b, g, x, y, width, height);
    } else {
      if (isPressed) {
        paintPressed(b, g, x, y, width, height);
      } else if (isRollover) {
        paintRollover(b, g, x, y, width, height);
      } else {
        paintNormal(b, g, x, y, width, height);
      }
    }
  }
}
 
源代码17 项目: snap-desktop   文件: ToolButtonFactory.java
private void setSelectedState(AbstractButton b) {
    if (b.isEnabled()) {
        b.setBorderPainted(true);
        b.setBackground(SELECTED_BACKGROUND_COLOR);
    } else {
        b.setBorderPainted(false);
        b.setBackground(getDefaultBackground().darker());
    }
}
 
源代码18 项目: rapidminer-studio   文件: RapidLookTools.java
/**
 * Draws the given button with the specified shape.
 *
 * @param b
 * @param g
 * @param shape
 */
public static void drawButton(AbstractButton b, Graphics g, Shape shape) {
	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	int h = (int) shape.getBounds().getHeight();
	ColorUIResource colorGradientStart;
	ColorUIResource colorGradientEnd;
	boolean highlighted = Boolean.parseBoolean(String.valueOf(b.getClientProperty(PROPERTY_BUTTON_HIGHLIGHT)));
	boolean highlightedDark = Boolean.parseBoolean(String.valueOf(b.getClientProperty(PROPERTY_BUTTON_HIGHLIGHT_DARK)));
	boolean highlightedWhite = Boolean.parseBoolean(String.valueOf(b.getClientProperty(PROPERTY_BUTTON_HIGHLIGHT_WHITE)));
	if (highlighted) {
		if (b.isEnabled()) {
			if (b.getModel().isPressed() || b.getModel().isSelected()) {
				colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_PRESSED_GRADIENT_START;
				colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_PRESSED_GRADIENT_END;
			} else if (b.getModel().isRollover()) {
				colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_ROLLOVER_GRADIENT_START;
				colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_ROLLOVER_GRADIENT_END;
			} else {
				colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_GRADIENT_START;
				colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_GRADIENT_END;
			}
		} else {
			colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DISABLED_GRADIENT_START;
			colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DISABLED_GRADIENT_END;
		}
	} else if (highlightedDark) {
		if (b.isEnabled()) {
			if (b.getModel().isPressed() || b.getModel().isSelected()) {
				colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_PRESSED_GRADIENT_START;
				colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_PRESSED_GRADIENT_END;
			} else if (b.getModel().isRollover()) {
				colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_ROLLOVER_GRADIENT_START;
				colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_ROLLOVER_GRADIENT_END;
			} else {
				colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_GRADIENT_START;
				colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_GRADIENT_END;
			}
		} else {
			colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_DISABLED_GRADIENT_START;
			colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_DISABLED_GRADIENT_END;
		}
	} else if (highlightedWhite) {
		if (b.isEnabled()) {
			if (b.getModel().isPressed() || b.getModel().isSelected()) {
				colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_PRESSED_GRADIENT_START;
				colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_PRESSED_GRADIENT_END;
			} else if (b.getModel().isRollover()) {
				colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_ROLLOVER_GRADIENT_START;
				colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_ROLLOVER_GRADIENT_END;
			} else {
				colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_GRADIENT_START;
				colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_GRADIENT_END;
			}
		} else {
			colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_DISABLED_GRADIENT_START;
			colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_DISABLED_GRADIENT_END;
		}
	} else {
		if (b.isEnabled()) {
			if (b.getModel().isPressed() || b.getModel().isSelected()) {
				colorGradientStart = Colors.BUTTON_BACKGROUND_PRESSED_GRADIENT_START;
				colorGradientEnd = Colors.BUTTON_BACKGROUND_PRESSED_GRADIENT_END;
			} else if (b.getModel().isRollover()) {
				colorGradientStart = Colors.BUTTON_BACKGROUND_ROLLOVER_GRADIENT_START;
				colorGradientEnd = Colors.BUTTON_BACKGROUND_ROLLOVER_GRADIENT_END;
			} else {
				colorGradientStart = Colors.BUTTON_BACKGROUND_GRADIENT_START;
				colorGradientEnd = Colors.BUTTON_BACKGROUND_GRADIENT_END;
			}
		} else {
			colorGradientStart = Colors.BUTTON_BACKGROUND_DISABLED_GRADIENT_START;
			colorGradientEnd = Colors.BUTTON_BACKGROUND_DISABLED_GRADIENT_END;
		}
	}

	Paint gp = new GradientPaint(0, 0, colorGradientStart, 0, h, colorGradientEnd);
	g2.setPaint(gp);

	g2.fill(shape);
}
 
源代码19 项目: snap-desktop   文件: ToolButtonFactory.java
private void setRolloverStateState(AbstractButton b) {
    if (b.isEnabled()) {
        b.setBorderPainted(true);
        b.setBackground(ROLLOVER_BACKGROUND_COLOR);
    }
}