javax.swing.JMenuItem.getForeground()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中javax.swing.JMenuItem.getForeground()方法的一些代码示例,展示了JMenuItem.getForeground()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.getForeground()方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:getForeground

JMenuItem.getForeground介绍

暂无

代码示例

代码示例来源:origin: log4j/log4j

protected void showLogLevelColorChangeDialog(JMenuItem result, LogLevel level) {
 JMenuItem menuItem = result;
 Color newColor = JColorChooser.showDialog(
   _logMonitorFrame,
   "Choose LogLevel Color",
   result.getForeground());
 if (newColor != null) {
  // set the color for the record
  level.setLogLevelColorMap(level, newColor);
  _table.getFilteredLogTableModel().refresh();
 }
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@ScriptFunction(jsDoc = FOREGROUND_JSDOC)
@Override
public Color getForeground() {
  return super.getForeground();
}

代码示例来源:origin: com.jidesoft/jide-oss

private Color getForegroundOfState(JMenuItem menuItem) {
  int state = JideSwingUtilities.getButtonState(menuItem);
  Color foreground = null;
  if (menuItem instanceof ComponentStateSupport) {
    foreground = ((ComponentStateSupport) menuItem).getForegroundOfState(state);
  }
  if (foreground == null || foreground instanceof UIResource) {
    foreground = menuItem.getForeground();
  }
  return foreground;
}

代码示例来源:origin: com.jidesoft/jide-oss

private Color getForegroundOfState(JMenuItem menuItem) {
  int state = JideSwingUtilities.getButtonState(menuItem);
  Color foreground = null;
  if (menuItem instanceof ComponentStateSupport) {
    foreground = ((ComponentStateSupport) menuItem).getForegroundOfState(state);
  }
  if (foreground == null || foreground instanceof UIResource) {
    foreground = menuItem.getForeground();
  }
  return foreground;
}

代码示例来源:origin: com.jidesoft/jide-oss

private Color getForegroundOfState(JMenuItem menuItem) {
  int state = JideSwingUtilities.getButtonState(menuItem);
  Color foreground = null;
  if (menuItem instanceof ComponentStateSupport) {
    foreground = ((ComponentStateSupport) menuItem).getForegroundOfState(state);
  }
  if (foreground == null || foreground instanceof UIResource) {
    foreground = menuItem.getForeground();
  }
  return foreground;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

protected void showLogLevelColorChangeDialog(JMenuItem result, LogLevel level) {
 JMenuItem menuItem = result;
 Color newColor = JColorChooser.showDialog(
   _logMonitorFrame,
   "Choose LogLevel Color",
   result.getForeground());
 if (newColor != null) {
  // set the color for the record
  level.setLogLevelColorMap(level, newColor);
  _table.getFilteredLogTableModel().refresh();
 }
}

代码示例来源:origin: org.apache.activemq/activemq-all

protected void showLogLevelColorChangeDialog(JMenuItem result, LogLevel level) {
 JMenuItem menuItem = result;
 Color newColor = JColorChooser.showDialog(
   _logMonitorFrame,
   "Choose LogLevel Color",
   result.getForeground());
 if (newColor != null) {
  // set the color for the record
  level.setLogLevelColorMap(level, newColor);
  _table.getFilteredLogTableModel().refresh();
 }
}

代码示例来源:origin: com.dorkbox/SystemTray

SwingMenuItemCheckbox(final SwingMenu parent, final Entry entry) {
  super(parent, entry);
  if (checkedIcon == null) {
    try {
      JMenuItem jMenuItem = new JMenuItem();
      // do the same modifications that would also happen (if specified) for the actual displayed menu items
      if (SystemTray.SWING_UI != null) {
        jMenuItem.setUI(SystemTray.SWING_UI.getItemUI(jMenuItem, null));
      }
      // Having the checkmark size the same size as the letter X is a reasonably nice size.
      int size = FontUtil.getFontHeight(jMenuItem.getFont(), "X");
      // this is the largest size of an image used in a JMenuItem, before the size of the JMenuItem is forced to be larger
      int menuImageSize = SystemTray.get()
                     .getMenuImageSize();
      String checkmarkPath;
      if (SystemTray.SWING_UI != null) {
        checkmarkPath = SystemTray.SWING_UI.getCheckMarkIcon(jMenuItem.getForeground(), size, menuImageSize);
      } else {
        checkmarkPath = HeavyCheckMark.get(jMenuItem.getForeground(), size, menuImageSize);
      }
      checkedIcon = new ImageIcon(checkmarkPath);
    } catch(Exception e) {
      SystemTray.logger.error("Error creating check-mark image.", e);
    }
  }
}

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
  if (!AbstractLookAndFeel.getTheme().isDarkTexture()) {
    super.paintText(g, menuItem, textRect, text);
    return;
  }
  ButtonModel model = menuItem.getModel();
  FontMetrics fm = JTattooUtilities.getFontMetrics(menuItem, g, menuItem.getFont());
  int mnemIndex = menuItem.getDisplayedMnemonicIndex();
  if (!menuItem.isArmed()) {
    g.setColor(Color.black);
    JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent() - 1);
  }
  if (!model.isEnabled()) {
    // *** paint the text disabled
    g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getDisabledForegroundColor(), 40));
  } else {
    // *** paint the text normally
    if (menuItem.isArmed()) {
      g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
    } else {
      Color foreColor = menuItem.getForeground();
      if (foreColor instanceof UIResource) {
        foreColor = AbstractLookAndFeel.getMenuForegroundColor();
      }
      g.setColor(foreColor);
    }
  }
  JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
}

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
    if (!AbstractLookAndFeel.getTheme().isDarkTexture()) {
      super.paintText(g, menuItem, textRect, text);
      return;
    }
    ButtonModel model = menuItem.getModel();
    FontMetrics fm = JTattooUtilities.getFontMetrics(menuItem, g, menuItem.getFont());
    int mnemIndex = menuItem.getDisplayedMnemonicIndex();
    if (!menuItem.isArmed()) {
      g.setColor(Color.black);
      JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent() - 1);
    }
    if (!model.isEnabled()) {
      // *** paint the text disabled
      g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getDisabledForegroundColor(), 40));
    } else {
      // *** paint the text normally
      if (menuItem.isArmed()) {
        g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
      } else {
        Color foreColor = menuItem.getForeground();
        if (foreColor instanceof UIResource) {
          foreColor = AbstractLookAndFeel.getMenuForegroundColor();
        }
        g.setColor(foreColor);
      }
    }
    JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
  }
}

代码示例来源:origin: com.jtattoo/JTattoo

g.setColor(Color.black);
JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent() - 1);
Color foreColor = menuItem.getForeground();
if (foreColor instanceof UIResource) {
  foreColor = AbstractLookAndFeel.getMenuForegroundColor();

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
    if (!AbstractLookAndFeel.getTheme().isDarkTexture()) {
      super.paintText(g, menuItem, textRect, text);
      return;
    }
    ButtonModel model = menuItem.getModel();
    FontMetrics fm = JTattooUtilities.getFontMetrics(menuItem, g, menuItem.getFont());
    int mnemIndex = menuItem.getDisplayedMnemonicIndex();
    if (!menuItem.isArmed()) {
      g.setColor(Color.black);
      JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent() - 1);
    }
    if (!model.isEnabled()) {
      // *** paint the text disabled
      g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getDisabledForegroundColor(), 40));
    } else {
      // *** paint the text normally
      if (menuItem.isArmed()) {
        g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
      } else {
        Color foreColor = menuItem.getForeground();
        if (foreColor instanceof UIResource) {
          foreColor = AbstractLookAndFeel.getMenuForegroundColor();
        }
        g.setColor(foreColor);
      }
    }
    JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
  }
}

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
    ButtonModel model = menuItem.getModel();
    Color foreColor = menuItem.getForeground();
    if (model.isArmed() || model.isRollover()) {
      foreColor = AbstractLookAndFeel.getMenuSelectionForegroundColor();
    } else if (foreColor == null || foreColor instanceof UIResource) {
      foreColor = AbstractLookAndFeel.getMenuForegroundColor();
    }
    Graphics2D g2D = (Graphics2D) g;
    Object savedRenderingHint = null;
    if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
      savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
      g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, AbstractLookAndFeel.getTheme().getTextAntiAliasingHint());
    }
    g2D.setColor(foreColor);
    super.paintText(g, menuItem, textRect, text);
    if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
      g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
    }
  }
}

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
  ButtonModel model = menuItem.getModel();
  Graphics2D g2D = (Graphics2D) g;
  Object savedRenderingHint = null;
  if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
    savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
    g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, AbstractLookAndFeel.getTheme().getTextAntiAliasingHint());
  }
  if (menuItem.getParent() instanceof JMenuBar) {
    if (model.isRollover() || model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) {
      g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
    }
  } else if (model.isArmed() || model.isRollover()) {
    g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
  } else {
    Color foreColor = menuItem.getForeground();
    if (foreColor instanceof UIResource) {
      foreColor = AbstractLookAndFeel.getMenuForegroundColor();
    }
    g.setColor(foreColor);
  }
  super.paintText(g, menuItem, textRect, text);
  if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
    g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
  }
}

代码示例来源:origin: com.jidesoft/jide-oss

ImageIcon image = IconsFactory.createMaskImage(b, checkIcon, Color.BLACK, b.getForeground());
image.paintIcon(b, g, checkIconRect.x, checkIconRect.y);

代码示例来源:origin: com.jidesoft/jide-oss

JideSwingUtilities.paintArrow(g, menuItem.getForeground(), middle - 2, menuHeight / 2 - 1, 5, SwingConstants.HORIZONTAL);

相关文章

JMenuItem类方法