本文整理了Java中javax.swing.JMenuItem.getBackground()
方法的一些代码示例,展示了JMenuItem.getBackground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.getBackground()
方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:getBackground
暂无
代码示例来源:origin: com.eas.platypus/platypus-js-forms
@ScriptFunction(jsDoc = BACKGROUND_JSDOC)
@Override
public Color getBackground() {
return super.getBackground();
}
代码示例来源:origin: GoldenGnu/jeveassets
private static void createMenuItemGroup(final JPopupMenu jPopupMenu, final String text, final Icon icon) {
JMenuItem jMenuItem = new JMenuItem(text);
if (icon != null) {
jMenuItem.setDisabledIcon(icon);
}
jMenuItem.setEnabled(false);
if (border == null) {
border = BorderFactory.createCompoundBorder(
BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(1, 0, 0, 0, jMenuItem.getBackground().darker()),
BorderFactory.createMatteBorder(1, 0, 0, 0, jMenuItem.getBackground().brighter())),
BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(0, 0, 1, 0, jMenuItem.getBackground().brighter()),
BorderFactory.createMatteBorder(0, 0, 1, 0, jMenuItem.getBackground().darker())));
}
jMenuItem.setForeground(Color.BLACK);
jMenuItem.setBorder(border);
jMenuItem.setBorderPainted(true);
jPopupMenu.add(jMenuItem);
}
代码示例来源:origin: com.fifesoft.rtext/fife.common
/**
* Workaround for the fact that not all LookAndFeels define
* MenuItem.background (such as MacLookAndFeel and WebLookAndFeel).
*/
private static void refreshMenuItemBackground() {
background = UIManager.getColor("MenuItem.background");
if (background==null || OS.get() == OS.MAC_OS_X ||
WebLookAndFeelUtils.isWebLookAndFeelInstalled()) {
background = new JMenuItem().getBackground();
}
if (UIUtil.isLightForeground(UIManager.getColor("Label.foreground"))) {
armedSwatchSelectionRectColor = new JPanel().getBackground().
brighter();
}
else {
armedSwatchSelectionRectColor = Color.BLACK;
}
}
代码示例来源:origin: com.jidesoft/jide-oss
/**
* Draws the background of the menu item.
*
* @param g the paint graphics
* @param menuItem menu item to be painted
* @param bgColor selection background color
* @since 1.4
*/
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();
if (menuItem.isOpaque()) {
if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) {
g.setColor(bgColor);
g.fillRect(0, 0, menuWidth, menuHeight);
}
else {
g.setColor(menuItem.getBackground());
g.fillRect(0, 0, menuWidth, menuHeight);
}
g.setColor(oldColor);
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
/** Draws the background of the menu item
*
* @param g The paint graphics
* @param menuItem Menu item to be painted
* @param bgColor Selection background color
*/
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();
if (menuItem.isOpaque())
{
g.setColor(menuItem.getBackground());
g.fillRect(0, 0, menuWidth, menuHeight);
if (model.isArmed()
|| (menuItem instanceof JMenu && model.isSelected()))
{
g.setColor(bgColor);
g.fillRect(1, 1, menuWidth-2, menuHeight-2);
}
g.setColor(oldColor);
}
}
代码示例来源:origin: net.sf.nimrod/nimrod-laf
g.setColor( menuItem.getBackground());
g.fillRect( 0,0, menuWidth, menuHeight);
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) {
JMenuItem mi = (JMenuItem) c;
Color backColor = mi.getBackground();
if (backColor == null || backColor instanceof UIResource) {
backColor = AbstractLookAndFeel.getMenuBackgroundColor();
}
ButtonModel model = mi.getModel();
if (model.isArmed() || model.isRollover() || (c instanceof JMenu && model.isSelected())) {
g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor());
g.fillRect(x, y, w, h);
g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
} else if (!AbstractLookAndFeel.getTheme().isMenuOpaque()) {
Graphics2D g2D = (Graphics2D) g;
Composite savedComposite = g2D.getComposite();
AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha());
g2D.setComposite(alpha);
g2D.setColor(backColor);
g2D.fillRect(x, y, w, h);
g2D.setComposite(savedComposite);
g.setColor(AbstractLookAndFeel.getMenuForegroundColor());
} else {
g.setColor(backColor);
g.fillRect(x, y, w, h);
g.setColor(AbstractLookAndFeel.getMenuForegroundColor());
}
}
代码示例来源:origin: com.jidesoft/jide-oss
if (menuItem.getBackground() instanceof UIResource) {
g.setColor(backgroundColor);
g.setColor(menuItem.getBackground());
代码示例来源:origin: com.jidesoft/jide-oss
g.setColor(menuItem.getBackground().brighter());
JideSwingUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex,
textRect.x,
textRect.y + fm.getAscent());
g.setColor(menuItem.getBackground().darker());
JideSwingUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex,
textRect.x - 1,
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
g.setColor(menuItem.getBackground().brighter());
BasicGraphicsUtils.drawStringUnderlineCharAt(
g,
textRect.x,
textRect.y + fm.getAscent());
g.setColor(menuItem.getBackground().darker());
BasicGraphicsUtils.drawStringUnderlineCharAt(
g,
代码示例来源:origin: com.jidesoft/jide-oss
g.setColor(menuItem.getBackground().brighter());
JideSwingUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex,
textRect.x,
textRect.y + fm.getAscent());
g.setColor(menuItem.getBackground().darker());
JideSwingUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex,
textRect.x - 1,
代码示例来源:origin: com.jidesoft/jide-oss
g.setColor(menuItem.getBackground());
g.fillRect(0, 0, menuWidth, menuHeight);
代码示例来源:origin: com.jidesoft/jide-oss
if (menuItem.getBackground() instanceof UIResource) {
g.setColor(getPainter().getMenuItemBackground());
g.setColor(menuItem.getBackground());
if (menuItem.getBackground() instanceof UIResource) {
g.setColor(getPainter().getMenuItemBackground());
g.setColor(menuItem.getBackground());
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) {
JMenuItem mi = (JMenuItem) c;
Color backColor = mi.getBackground();
if (backColor == null || backColor instanceof UIResource) {
backColor = AbstractLookAndFeel.getMenuBackgroundColor();
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) {
JMenuItem mi = (JMenuItem) c;
ButtonModel model = mi.getModel();
if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
TextureUtils.fillComponent(g, c, TextureUtils.ROLLOVER_TEXTURE_TYPE);
} else {
if (!(mi.getBackground() instanceof ColorUIResource)) {
super.paintBackground(g, c, x, y, w, h);
} else {
TextureUtils.fillComponent(g, c, TextureUtils.MENUBAR_TEXTURE_TYPE);
}
}
}
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) {
JMenuItem mi = (JMenuItem) c;
ButtonModel model = mi.getModel();
if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
TextureUtils.fillComponent(g, c, TextureUtils.ROLLOVER_TEXTURE_TYPE);
} else {
if (!(mi.getBackground() instanceof ColorUIResource)) {
super.paintBackground(g, c, x, y, w, h);
} else {
TextureUtils.fillComponent(g, c, TextureUtils.MENUBAR_TEXTURE_TYPE);
}
}
}
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) {
JMenuItem mi = (JMenuItem) c;
ButtonModel model = mi.getModel();
if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
TextureUtils.fillComponent(g, c, TextureUtils.ROLLOVER_TEXTURE_TYPE);
} else {
if (!(mi.getBackground() instanceof ColorUIResource)) {
super.paintBackground(g, c, x, y, w, h);
} else {
TextureUtils.fillComponent(g, c, TextureUtils.MENUBAR_TEXTURE_TYPE);
}
}
}
代码示例来源:origin: com.jidesoft/jide-oss
g.setColor(menuItem.getBackground());
代码示例来源:origin: com.jidesoft/jide-oss
g.setColor(menuItem.getBackground());
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) {
JMenuItem mi = (JMenuItem) c;
ButtonModel model = mi.getModel();
if (c.getParent() instanceof JMenuBar) {
if (model.isRollover() || model.isArmed() || (c instanceof JMenu && model.isSelected())) {
TextureUtils.fillComponent(g, c, TextureUtils.ROLLOVER_TEXTURE_TYPE);
}
} else {
if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
TextureUtils.fillComponent(g, c, TextureUtils.ROLLOVER_TEXTURE_TYPE);
} else {
if (!(mi.getBackground() instanceof ColorUIResource)) {
super.paintBackground(g, c, x, y, w, h);
} else {
TextureUtils.fillComponent(g, c, TextureUtils.MENUBAR_TEXTURE_TYPE);
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!