当前位置: 首页>>代码示例>>Java>>正文


Java ButtonModel.isSelected方法代码示例

本文整理汇总了Java中javax.swing.ButtonModel.isSelected方法的典型用法代码示例。如果您正苦于以下问题:Java ButtonModel.isSelected方法的具体用法?Java ButtonModel.isSelected怎么用?Java ButtonModel.isSelected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.ButtonModel的用法示例。


在下文中一共展示了ButtonModel.isSelected方法的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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:CheckBoxMenuItemIcon.java

示例2: 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);
	}
 
开发者ID:kmarius,项目名称:xdman,代码行数:22,代码来源:XDMMenuUI.java

示例3: paintIcon

import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paintIcon(Graphics2D g,ButtonInfo info) {
	AbstractButton button = info.button;
	Icon icon = button.getIcon();
	ButtonModel model = button.getModel();

	if(model.isRollover() && button.getRolloverIcon()!=null)
		icon = button.getRolloverIcon();
	if(model.isPressed() && button.getPressedIcon()!=null)
		icon = button.getPressedIcon();
	if(model.isSelected() && button.getSelectedIcon()!=null)
		icon = button.getSelectedIcon();
	if(model.isRollover() && model.isSelected() && button.getRolloverSelectedIcon()!=null)
		icon = button.getRolloverSelectedIcon();
	if(isEnabled(button)==false && button.getDisabledIcon()!=null)
		icon = button.getDisabledIcon();
	if(isEnabled(button)==false && model.isSelected() && button.getDisabledIcon()!=null)
		icon = button.getDisabledSelectedIcon();

	if(icon!=null) {
		g.setComposite(isEnabled(button) ? AlphaComposite.SrcOver : SRC_OVER_TRANSLUCENT);
		icon.paintIcon(button, g, info.iconRect.x, info.iconRect.y);
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:24,代码来源:FilledButtonUI.java

示例4: paintBackground

import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
public void paintBackground(Graphics2D g,ButtonInfo info) {
	super.paintBackground(g, info);
	if(info.button.isContentAreaFilled() || info.button.isBorderPainted()) {
		ButtonModel model = info.button.getModel();
		if(model.isSelected() || model.isArmed() || isSpacebarPressed(info.button)) {
			g = (Graphics2D)g.create();
			
			g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
					RenderingHints.VALUE_ANTIALIAS_ON);
			g.clip( info.fill);
			g.setColor(new Color(0,0,0,15));
			g.setStroke(outline1);
			g.draw( info.fill );
			g.setStroke(outline2);
			g.draw( info.fill );
			g.setStroke(outline3);
			g.draw( info.fill );
		}
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:22,代码来源:TexturedButtonUI.java

示例5: 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();
    }
}
 
开发者ID:freeseawind,项目名称:littleluck,代码行数:29,代码来源:LuckCheckboxIcon.java

示例6: getPreImg

import javax.swing.ButtonModel; //导入方法依赖的package包/类
public Image getPreImg(Component c, ButtonModel model)
{
    JMenu menu = (JMenu) c;

    if (menu.getItemCount() > 0)
    {
        if (model.isSelected())
        {
            return getRollverImg();
        }
        else
        {
            return getNormalImg();
        }
    }

    return null;
}
 
开发者ID:freeseawind,项目名称:littleluck,代码行数:19,代码来源:LuckArrowIcon.java

示例7: 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);
}
 
开发者ID:vilie,项目名称:javify,代码行数:29,代码来源:BasicMenuItemUI.java

示例8: 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);
}
 
开发者ID:Bolt-Thrower,项目名称:xdm,代码行数:18,代码来源:XDMMenuItemUI.java

示例9: getIcon

import javax.swing.ButtonModel; //导入方法依赖的package包/类
private Icon getIcon(JMenuItem aMenuItem, Icon defaultIcon)
/*  63:    */   {
/*  64:114 */     Icon icon = aMenuItem.getIcon();
/*  65:115 */     if (icon == null) {
/*  66:116 */       return defaultIcon;
/*  67:    */     }
/*  68:118 */     ButtonModel model = aMenuItem.getModel();
/*  69:119 */     if (!model.isEnabled()) {
/*  70:120 */       return model.isSelected() ? aMenuItem.getDisabledSelectedIcon() : aMenuItem.getDisabledIcon();
/*  71:    */     }
/*  72:123 */     if ((model.isPressed()) && (model.isArmed()))
/*  73:    */     {
/*  74:124 */       Icon pressedIcon = aMenuItem.getPressedIcon();
/*  75:125 */       return pressedIcon != null ? pressedIcon : icon;
/*  76:    */     }
/*  77:126 */     if (model.isSelected())
/*  78:    */     {
/*  79:127 */       Icon selectedIcon = aMenuItem.getSelectedIcon();
/*  80:128 */       return selectedIcon != null ? selectedIcon : icon;
/*  81:    */     }
/*  82:130 */     return icon;
/*  83:    */   }
 
开发者ID:xiwc,项目名称:confluence.keygen,代码行数:23,代码来源:MenuItemRenderer.java

示例10: ensureSubMenuInstalled

import javax.swing.ButtonModel; //导入方法依赖的package包/类
private void ensureSubMenuInstalled()
/*  92:    */   {
/*  93:156 */     if (this.propertyPrefix.equals("MenuItem")) {
/*  94:157 */       return;
/*  95:    */     }
/*  96:159 */     ButtonModel model = this.menuItem.getModel();
/*  97:    */     
/*  98:    */ 
/*  99:    */ 
/* 100:163 */     boolean oldArmed = model.isArmed();
/* 101:164 */     boolean oldSelected = model.isSelected();
/* 102:    */     
/* 103:166 */     uninstallRolloverListener();
/* 104:167 */     uninstallDefaults();
/* 105:168 */     this.propertyPrefix = "MenuItem";
/* 106:169 */     installDefaults();
/* 107:    */     
/* 108:    */ 
/* 109:172 */     model.setArmed(oldArmed);
/* 110:173 */     model.setSelected(oldSelected);
/* 111:    */   }
 
开发者ID:xiwc,项目名称:confluence.keygen,代码行数:22,代码来源:ExtBasicMenuUI.java

示例11: setSelected

import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void setSelected(ButtonModel m, boolean b) {
    if (b == false) {
        for (ButtonModel model : selected) {
            if (model.isSelected() && model != m) {
                selected.remove(m);
                return;
            }
        }
    } else {
        selected.add(m);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:MultiButtonGroup.java

示例12: store

import javax.swing.ButtonModel; //导入方法依赖的package包/类
/** Stores all models created in the StoreGroup into given
 * EditableProperties.
 * @param editableProperties The properties where to store the
 *        values.
 */
public void store( EditableProperties editableProperties ) {
    for (Map.Entry<String,Object[]> entry : models.entrySet()) {
        String key = entry.getKey();
        Object[] params = entry.getValue();

        if ( params[0] instanceof ButtonModel ) {
            ButtonModel model = (ButtonModel)params[0];
            boolean value = model.isSelected();
            if ( params[2] == Boolean.TRUE ) {
                value = !value;
            }
            editableProperties.setProperty( key, encodeBoolean( value, (Integer)params[1] ) );
        }
        else if ( params[0] instanceof Document && modifiedDocuments.contains(params[0])) {
            Document doc = (Document)params[0];
            String txt;
            try {
                txt = doc.getText(0, doc.getLength());
            } catch (BadLocationException e) {
                txt = ""; // NOI18N
            }                    
            editableProperties.setProperty( key, txt );
        }

    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:StoreGroup.java

示例13: 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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:15,代码来源:RapidLookTools.java

示例14: 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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:35,代码来源:MenuUI.java

示例15: 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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:CardButton.java


注:本文中的javax.swing.ButtonModel.isSelected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。