本文整理汇总了Java中javax.swing.ButtonModel.isEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java ButtonModel.isEnabled方法的具体用法?Java ButtonModel.isEnabled怎么用?Java ButtonModel.isEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.ButtonModel
的用法示例。
在下文中一共展示了ButtonModel.isEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintIcon
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
JMenuItem b = (JMenuItem) c;
ButtonModel model = b.getModel();
g.translate(x, y);
boolean isSelected = model.isSelected();
boolean isEnabled = model.isEnabled();
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// draw check mark
if (isSelected) {
g2.setStroke(CHECKBOX_STROKE);
if (isEnabled) {
g2.setColor(Colors.CHECKBOX_CHECKED);
} else {
g2.setColor(Colors.CHECKBOX_CHECKED_DISABLED);
}
g2.drawLine(2, 6, 5, 8);
g2.drawLine(5, 8, 9, 1);
}
g.translate(-x, -y);
}
示例2: paintIcon
import javax.swing.ButtonModel; //导入方法依赖的package包/类
static void paintIcon(Graphics g, SeaGlassMenuItemLayoutHelper lh,
MenuItemLayoutHelper.LayoutResult lr) {
if (lh.getIcon() != null) {
Icon icon;
JMenuItem mi = lh.getMenuItem();
ButtonModel model = mi.getModel();
if (!model.isEnabled()) {
icon = mi.getDisabledIcon();
} else if (model.isPressed() && model.isArmed()) {
icon = mi.getPressedIcon();
if (icon == null) {
// Use default icon
icon = mi.getIcon();
}
} else {
icon = mi.getIcon();
}
if (icon != null) {
Rectangle iconRect = lr.getIconRect();
SynthIcon.paintIcon(icon, lh.getContext(), g, iconRect.x,
iconRect.y, iconRect.width, iconRect.height);
}
}
}
示例3: getIcon
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* Returns the Icon to use in painting the button.
*
* @param b the button.
*
* @return the icon.
*/
protected Icon getIcon(AbstractButton b) {
Icon icon = b.getIcon();
ButtonModel model = b.getModel();
if (!model.isEnabled()) {
icon = getSynthDisabledIcon(b, icon);
} else if (model.isPressed() && model.isArmed()) {
icon = getPressedIcon(b, getSelectedIcon(b, icon));
} else if (b.isRolloverEnabled() && model.isRollover()) {
icon = getRolloverIcon(b, getSelectedIcon(b, icon));
} else if (model.isSelected()) {
icon = getSelectedIcon(b, icon);
} else {
icon = getEnabledIcon(b, icon);
}
if (icon == null) {
return getDefaultIcon(b);
}
return icon;
}
示例4: paintBorder
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
/* 101: */ {
/* 102:176 */ AbstractButton button = (AbstractButton)c;
/* 103:177 */ ButtonModel model = button.getModel();
/* 104:179 */ if (!model.isEnabled())
/* 105: */ {
/* 106:180 */ PlasticXPUtils.drawDisabledButtonBorder(g, x, y, w, h);
/* 107:181 */ return;
/* 108: */ }
/* 109:184 */ boolean isPressed = (model.isPressed()) && (model.isArmed());
/* 110:185 */ boolean isDefault = ((button instanceof JButton)) && (((JButton)button).isDefaultButton());
/* 111: */
/* 112:187 */ boolean isFocused = (button.isFocusPainted()) && (button.hasFocus());
/* 113:189 */ if (isPressed) {
/* 114:190 */ PlasticXPUtils.drawPressedButtonBorder(g, x, y, w, h);
/* 115:191 */ } else if (isFocused) {
/* 116:192 */ PlasticXPUtils.drawFocusedButtonBorder(g, x, y, w, h);
/* 117:193 */ } else if (isDefault) {
/* 118:194 */ PlasticXPUtils.drawDefaultButtonBorder(g, x, y, w, h);
/* 119: */ } else {
/* 120:196 */ PlasticXPUtils.drawPlainButtonBorder(g, x, y, w, h);
/* 121: */ }
/* 122: */ }
示例5: paintIcon
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
public void paintIcon(final Component component, final Graphics graphics, final int x, final int y) {
final AbstractButton button = (AbstractButton) component;
final ButtonModel buttonModel = button.getModel();
final int width = WIDTH - 2;
final int height = HEIGHT;
graphics.translate(x, y);
String colorUI = null;
if (buttonModel.isEnabled()) {
colorUI = "controlText";
}
else {
colorUI = "textInactiveText";
}
graphics.setColor(UIManager.getColor(colorUI));
for (int i = 0; i < height; i++) {
graphics.drawLine(i + 1, i, width - i, i);
}
graphics.translate(-x, -y);
}
示例6: paintBorder
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
/* 278: */ {
/* 279:410 */ AbstractButton button = (AbstractButton)c;
/* 280:411 */ ButtonModel model = button.getModel();
/* 281:413 */ if (model.isEnabled())
/* 282: */ {
/* 283:414 */ boolean isPressed = (model.isPressed()) && (model.isArmed());
/* 284:416 */ if (isPressed) {
/* 285:417 */ PlasticUtils.drawPressed3DBorder(g, x, y, w, h);
/* 286: */ } else {
/* 287:419 */ PlasticUtils.drawButtonBorder(g, x, y, w, h, false);
/* 288: */ }
/* 289: */ }
/* 290: */ else
/* 291: */ {
/* 292:421 */ PlasticUtils.drawDisabledBorder(g, x, y, w - 1, h - 1);
/* 293: */ }
/* 294: */ }
示例7: paintBackground
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
JMenu menu = (JMenu) menuItem;
ButtonModel buttonmodel = menu.getModel();
int w = menu.getWidth();
int h = menu.getHeight();
Color oldColor = g.getColor();
if (!menu.isContentAreaFilled() || !menu.isOpaque()) {
// do nothing
} else {
if (menu.isTopLevelMenu()) {
if (buttonmodel.isSelected()) {
CachedPainter.drawMenuBackground(menuItem, g, 0, 0, w, h);
} else if (buttonmodel.isRollover() && buttonmodel.isEnabled()) {
g.setColor(Colors.MENUBAR_BACKGROUND_HIGHLIGHT);
g.fillRect(0, 0, w, h);
g.setColor(Colors.MENU_ITEM_BACKGROUND);
g.drawRect(0, 0, w - 1, h - 1);
} else {
if (menuItem.getParent() instanceof JMenuBar) {
((MenuBarUI) ((JMenuBar) menuItem.getParent()).getUI()).update(g, menuItem);
}
}
} else {
if (!menuItem.getModel().isSelected()) {
RapidLookTools.drawMenuItemFading(menuItem, g);
} else {
RapidLookTools.drawMenuItemBackground(g, menuItem);
}
}
}
g.setColor(oldColor);
}
示例8: paintComponent
import javax.swing.ButtonModel; //导入方法依赖的package包/类
protected void paintComponent(Graphics graphics) {
SwingTools.disableClearType(this);
((Graphics2D)graphics).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Graphics2D g = (Graphics2D)graphics.create();
ButtonModel model = this.getModel();
if(model.isEnabled() && (model.isRollover() || model.isSelected())) {
g.setColor(this.colorHover);
g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 10, 10);
}
g.dispose();
super.paintComponent(graphics);
}
示例9: paintIcon
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
AbstractButton abstractButton = (AbstractButton) c;
ButtonModel buttonModel = abstractButton.getModel();
int w = getIconWidth();
int h = getIconHeight();
if (g instanceof Graphics2D) {
Graphics2D g2 = (Graphics2D) g;
RenderingHints rh = new RenderingHints(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHints(rh);
float s = SizeHelper.getMinimalStrockWidth();
g2.setStroke(new BasicStroke(s));
}
g.setColor(Color.WHITE);
g.fillRect(x, y, w, h);
if (buttonModel.isEnabled()) {
g.setColor(Color.BLACK);
} else {
g.setColor(Color.GRAY);
}
g.drawRect(x, y, w, h);
if (buttonModel.isSelected()) {
g.drawLine(x + 1, y + 1, x + w - 1, y + h - 1);
g.drawLine(x + w - 1, y + 1, x + 1, y + h - 1);
}
}
示例10: paint
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paint(Graphics g, JComponent c) {
AbstractButton button = (AbstractButton)c;
if (button.getModel().isSelected()) {
Color oldColor = g.getColor();
g.setColor(selectedBackground);
g.fillRoundRect(0, 0, c.getWidth() - 1, c.getHeight() - 1, 5, 5);
g.setColor(selectedBorder);
g.drawRoundRect(0, 0, c.getWidth() - 1, c.getHeight() - 1, 5, 5);
g.setColor(oldColor);
}
// this is a tweak to get the View with the color we expect it to be. We
// change directly the color of the button
if (c.getClientProperty(BasicHTML.propertyKey) != null) {
ButtonModel model = button.getModel();
if (model.isEnabled()) {
if (model.isSelected()) {
button.setForeground(selectedForeground);
} else {
button.setForeground(unselectedForeground);
}
} else {
button.setForeground(unselectedForeground.darker());
}
}
super.paint(g, c);
}
示例11: paintComponent
import javax.swing.ButtonModel; //导入方法依赖的package包/类
protected void paintComponent(Graphics g) {
Color c1, c2, c3;
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
ButtonModel m = getModel();
Paint oldPaint = g2.getPaint();
if (m.isArmed()) {
c2 = color1.darker();
c1 = color2.darker();
c3 = color3;
} else {
c1 = color1.darker();
c2 = color2.darker();
c3 = color3.brighter();
}
if (!m.isEnabled()) {
c2 = color1.brighter();
c1 = color2.brighter();
c3 = color3.darker();
}
RoundRectangle2D.Float r2d = new RoundRectangle2D.Float(0, 0,
getWidth(), getHeight() - 1, 20, 20);
g2.clip(r2d);
g2.setPaint(new GradientPaint(0.0f, 0.0f, c1, 0.0f, getHeight(), c2));
g2.fillRect(0, 0, getWidth(), getHeight());
g2.setStroke(new BasicStroke(4f));
g2.setPaint(new GradientPaint(0.0f, 0.0f, c3, 0.0f, getHeight(), c3));
g2.drawRoundRect(0, 0, getWidth() - 2, getHeight() - 2, 18, 18);
g2.setPaint(oldPaint);
super.paintComponent(g);
}
示例12: paintText
import javax.swing.ButtonModel; //导入方法依赖的package包/类
private void paintText(Graphics g, JMenuItem aMenuItem, Rectangle textRectangle, String text)
/* 446: */ {
/* 447:596 */ ButtonModel model = aMenuItem.getModel();
/* 448:597 */ FontMetrics fm = g.getFontMetrics();
/* 449:598 */ int mnemIndex = aMenuItem.getDisplayedMnemonicIndex();
/* 450:599 */ if (isMnemonicHidden()) {
/* 451:600 */ mnemIndex = -1;
/* 452: */ }
/* 453:603 */ if (!model.isEnabled())
/* 454: */ {
/* 455:604 */ if (!disabledTextHasShadow())
/* 456: */ {
/* 457:606 */ g.setColor(UIManager.getColor("MenuItem.disabledForeground"));
/* 458:607 */ RenderingUtils.drawStringUnderlineCharAt(aMenuItem, g, text, mnemIndex, textRectangle.x, textRectangle.y + fm.getAscent());
/* 459: */ }
/* 460: */ else
/* 461: */ {
/* 462:612 */ g.setColor(aMenuItem.getBackground().brighter());
/* 463:613 */ RenderingUtils.drawStringUnderlineCharAt(aMenuItem, g, text, mnemIndex, textRectangle.x, textRectangle.y + fm.getAscent());
/* 464: */
/* 465: */
/* 466:616 */ g.setColor(aMenuItem.getBackground().darker());
/* 467:617 */ RenderingUtils.drawStringUnderlineCharAt(aMenuItem, g, text, mnemIndex, textRectangle.x - 1, textRectangle.y + fm.getAscent() - 1);
/* 468: */ }
/* 469: */ }
/* 470: */ else
/* 471: */ {
/* 472:623 */ if ((model.isArmed()) || (((aMenuItem instanceof JMenu)) && (model.isSelected()))) {
/* 473:624 */ g.setColor(this.selectionForeground);
/* 474: */ }
/* 475:626 */ RenderingUtils.drawStringUnderlineCharAt(aMenuItem, g, text, mnemIndex, textRectangle.x, textRectangle.y + fm.getAscent());
/* 476: */ }
/* 477: */ }
示例13: paintIcon
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paintIcon(Component c, Graphics g, int x, int y)
{
JCheckBox cb = (JCheckBox) c;
ButtonModel model = cb.getModel();
//选中时
if(model.isSelected())
{
//处于禁用状态
if(!model.isEnabled())
g.drawImage(__IconFactory__.getInstance().getCheckBoxButtonIcon_disable().getImage(), x, y, null);
else
{
//处于被按住状态
if(model.isPressed())
g.drawImage(__IconFactory__.getInstance().getCheckBoxButtonIcon_pressed().getImage(), x, y, null);
else
g.drawImage(__IconFactory__.getInstance().getCheckBoxButtonIcon_normal().getImage(), x, y, null);
}
}
//未选中时
else
{
//处于禁用状态
if(!model.isEnabled())
g.drawImage(__IconFactory__.getInstance().getCheckBoxButtonIcon_unchecked_disable().getImage(), x, y, null);
else
{
//处于被按住状态
if(model.isPressed())
g.drawImage(__IconFactory__.getInstance().getCheckBoxButtonIcon_unchecked_pressed().getImage(), x, y, null);
else
g.drawImage(__IconFactory__.getInstance().getCheckBoxButtonIcon_unchecked_normal().getImage(), x, y, null);
}
}
}
示例14: is3D
import javax.swing.ButtonModel; //导入方法依赖的package包/类
protected boolean is3D(AbstractButton b)
/* 82: */ {
/* 83:140 */ if (PlasticUtils.force3D(b)) {
/* 84:141 */ return true;
/* 85: */ }
/* 86:142 */ if (PlasticUtils.forceFlat(b)) {
/* 87:143 */ return false;
/* 88: */ }
/* 89:144 */ ButtonModel model = b.getModel();
/* 90:145 */ return (PlasticUtils.is3D("Button.")) && (b.isBorderPainted()) && (model.isEnabled()) && ((!model.isPressed()) || (!model.isArmed()));
/* 91: */ }
示例15: is3D
import javax.swing.ButtonModel; //导入方法依赖的package包/类
protected boolean is3D(AbstractButton b)
/* 146: */ {
/* 147:227 */ if (PlasticUtils.force3D(b)) {
/* 148:228 */ return true;
/* 149: */ }
/* 150:229 */ if (PlasticUtils.forceFlat(b)) {
/* 151:230 */ return false;
/* 152: */ }
/* 153:231 */ ButtonModel model = b.getModel();
/* 154:232 */ return (PlasticUtils.is3D("ToggleButton.")) && (b.isBorderPainted()) && (model.isEnabled()) && (!model.isPressed());
/* 155: */ }