本文整理汇总了Java中javax.swing.ButtonModel.isArmed方法的典型用法代码示例。如果您正苦于以下问题:Java ButtonModel.isArmed方法的具体用法?Java ButtonModel.isArmed怎么用?Java ButtonModel.isArmed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.ButtonModel
的用法示例。
在下文中一共展示了ButtonModel.isArmed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintBackground
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
ButtonModel model = menuItem.getModel();
Color oldColor = g.getColor();
if (model.isArmed()
|| (menuItem instanceof JMenu && model.isSelected())) {
paintButtonPressed(g, menuItem);
} else {
g.setColor(this.colorBg);
//g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());//(0, 0, gap + 1, menuItem.getHeight());
// g.drawLine(gap + 1, 0, gap + 1, menuItem.getHeight());
// if (menuItem.getIcon() != null) {
// int gap = menuItem.getIcon().getIconWidth() + 2;
// g.setColor(this.darkColor);
// g.drawLine(gap, 0, gap, menuItem.getHeight());
// g.setColor(this.lightColor);
// g.drawLine(gap + 1, 0, gap + 1, menuItem.getHeight());
// }
}
g.setColor(oldColor);
}
示例2: paint
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* Paints the Button
*
* @param g
* The graphics
* @param c
* The component
*/
@Override
public void paint(final Graphics g, final JComponent c) {
// super.paint(g, c);
final AbstractButton button = (AbstractButton) c;
button.setRolloverEnabled(true);
final ButtonModel model = button.getModel();
final Rectangle bounds = button.getBounds();
if (model.isPressed() && model.isArmed()) {
g.translate(1, 1);
super.paint(g, c);
g.translate(-1, -1);
downBorder.paintBorder(c, g, 0, 0, bounds.width, bounds.height);
} else if (button.isRolloverEnabled() && model.isRollover()) {
super.paint(g, c);
upBorder.paintBorder(c, g, 0, 0, bounds.width, bounds.height);
} else {
super.paint(g, c);
}
}
示例3: paintIcon
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* Paint the icon for this component. Depending on the state of the
* component and the availability of the button's various icon
* properties, this might mean painting one of several different icons.
*
* @param g Graphics context to paint with
* @param c Component to paint the icon of
* @param iconRect Rectangle in which the icon should be painted
*/
protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect)
{
AbstractButton b = (AbstractButton) c;
Icon i = currentIcon(b);
if (i != null)
{
ButtonModel m = b.getModel();
if (m.isPressed() && m.isArmed())
{
int offs = getTextShiftOffset();
i.paintIcon(c, g, iconRect.x + offs, iconRect.y + offs);
}
else
i.paintIcon(c, g, iconRect.x, iconRect.y);
}
}
示例4: getPreImg
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* <pre>
* 根据按钮状态, 获取当前状态下图片信息。
*
* According to the button state, access to the current
* state of the picture information.
* </pre>
*
* @param c <code>CheckBoxMenuItem</code> object.
* @param model <code>ButtonModel</code>
* @return <code>Image</code> when is selected return current image, otherwise return null.
*/
public Image getPreImg(Component c, ButtonModel model)
{
if (!model.isSelected())
{
return null;
}
if (model.isArmed())
{
return getRollverImg();
}
else
{
return getNormalImg();
}
}
示例5: paint
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paint(Graphics g, JComponent c)
{
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
paintBg(g, (AbstractButton) c);
// 设置组件偏移,以达到视觉上的按下和弹起效果
// Set the component offsets to achieve visual depress and bounce
if(model.isPressed() && model.isArmed() && b.getIcon() == null)
{
g.translate(2, 1);
}
super.paint(g, c);
if(model.isPressed() && model.isArmed() && b.getIcon() == null)
{
g.translate(-2, -1);
}
}
示例6: update
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* If the property <code>ToggleButton.gradient</code> is set, then a gradient
* is painted as background, otherwise the normal superclass behaviour is
* called.
*/
public void update(Graphics g, JComponent c)
{
AbstractButton b = (AbstractButton) c;
ButtonModel m = b.getModel();
if (b.getBackground() instanceof UIResource
&& b.isContentAreaFilled()
&& b.isEnabled() && ! m.isArmed() && ! m.isPressed()
&& UIManager.get(getPropertyPrefix() + "gradient") != null)
{
MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
SwingConstants.VERTICAL,
getPropertyPrefix() + "gradient");
paint(g, c);
}
else
super.update(g, c);
}
示例7: paintBackground
import javax.swing.ButtonModel; //导入方法依赖的package包/类
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
ButtonModel model = menuItem.getModel();
Color oldColor = g.getColor();
int menuWidth = menuItem.getWidth();
int menuHeight = menuItem.getHeight();
g.setColor(this.colorBg);
g.fillRect(0, 0, menuWidth, menuHeight);
if(model.isArmed() || menuItem instanceof JMenu && model.isSelected()) {
this.paintButtonPressed(g, menuItem);
}
if(menuItem instanceof JCheckBoxMenuItem) {
((JCheckBoxMenuItem)menuItem).isSelected();
}
g.setColor(oldColor);
}
示例8: paintBackground
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* Paints background of the menu item
*
* @param g
* The graphics context used to paint this menu item
* @param menuItem
* menu item to paint
* @param bgColor
* Background color to use when painting menu item
*/
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
{
// Menu item is considered to be highlighted when it is selected.
// But we don't want to paint the background of JCheckBoxMenuItems
ButtonModel mod = menuItem.getModel();
Color saved = g.getColor();
if (mod.isArmed() || ((menuItem instanceof JMenu) && mod.isSelected()))
{
g.setColor(bgColor);
g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
}
else if (menuItem.isOpaque())
{
g.setColor(menuItem.getBackground());
g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
}
g.setColor(saved);
}
示例9: 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);
}
}
}
示例10: paintBorder
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
/* 702: */ {
/* 703:783 */ if (!c.isEnabled())
/* 704: */ {
/* 705:784 */ PlasticUtils.drawDisabledBorder(g, x, y, w - 1, h - 1);
/* 706: */ }
/* 707: */ else
/* 708: */ {
/* 709:786 */ AbstractButton button = (AbstractButton)c;
/* 710:787 */ ButtonModel model = button.getModel();
/* 711:788 */ if ((model.isPressed()) && (model.isArmed())) {
/* 712:789 */ PlasticUtils.drawPressed3DBorder(g, x, y, w, h);
/* 713:790 */ } else if (model.isSelected()) {
/* 714:791 */ PlasticUtils.drawDark3DBorder(g, x, y, w, h);
/* 715: */ } else {
/* 716:793 */ PlasticUtils.drawFlush3DBorder(g, x, y, w, h);
/* 717: */ }
/* 718: */ }
/* 719: */ }
示例11: paintBackground
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* Paints background of the menu item
*
* @param g
* The graphics context used to paint this menu item
* @param menuItem
* menu item to paint
* @param bgColor
* Background color to use when painting menu item
*/
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
{
// Menu item is considered to be highlighted when it is selected.
// But we don't want to paint the background of JCheckBoxMenuItems
ButtonModel mod = menuItem.getModel();
Color saved = g.getColor();
if (mod.isArmed() || ((menuItem instanceof JMenu) && mod.isSelected()))
{
g.setColor(bgColor);
g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
}
else if (menuItem.isOpaque())
{
g.setColor(menuItem.getBackground());
g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
}
g.setColor(saved);
}
示例12: drawMenuItemBackground
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public static void drawMenuItemBackground(Graphics g, JMenuItem menuItem) {
Color oldColor = g.getColor();
ButtonModel model = menuItem.getModel();
int w = menuItem.getWidth();
int h = menuItem.getHeight();
if (model.isArmed() || model.isSelected() && menuItem instanceof JMenu) {
g.setColor(Colors.MENU_ITEM_BACKGROUND_SELECTED);
g.fillRect(0, 0, w, h);
} else if (!(menuItem instanceof JMenu && ((JMenu) menuItem).isTopLevelMenu())) {
drawMenuItemFading(menuItem, g);
}
g.setColor(oldColor);
}
示例13: paintBackground
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
ButtonModel model = menuItem.getModel();
Color oldColor = g.getColor();
int menuWidth = menuItem.getWidth();
int menuHeight = menuItem.getHeight();
g.setColor(colorBg);
g.fillRect(0, 0, menuWidth, menuHeight);
if (model.isArmed()
|| (menuItem instanceof JMenu && model.isSelected())) {
paintButtonPressed(g, menuItem);
} else {
// if (menuItem.getIcon() != null) {
// int gap = menuItem.getIcon().getIconWidth() + 2;
// g.setColor(this.darkColor);
// g.drawLine(gap, 0, gap, menuItem.getHeight());
// g.setColor(this.lightColor);
// g.drawLine(gap + 1, 0, gap + 1, menuItem.getHeight());
// }
}
if (menuItem instanceof JCheckBoxMenuItem) {
if (((JCheckBoxMenuItem) menuItem).isSelected()) {
// chkIcon.paintIcon(menuItem, g, 5, 5);
}
}
g.setColor(oldColor);
}
示例14: paintBorder
import javax.swing.ButtonModel; //导入方法依赖的package包/类
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);
}
}
}
}
示例15: paintBackground
import javax.swing.ButtonModel; //导入方法依赖的package包/类
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
ButtonModel model = menuItem.getModel();
Color oldColor = g.getColor();
if(!model.isArmed() && (!(menuItem instanceof JMenu) || !model.isSelected())) {
g.setColor(this.colorBg);
} else {
this.paintButtonPressed(g, menuItem);
}
g.setColor(oldColor);
}