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

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

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

JMenuItem.setForeground介绍

暂无

代码示例

代码示例来源:origin: Audiveris/audiveris

private static void addColoredItem (JComponent top,
                  JMenuItem item,
                  Color color)
{
  if (color != null) {
    item.setForeground(color);
  } else {
    item.setForeground(Color.black);
  }
  top.add(item);
}

代码示例来源:origin: stackoverflow.com

JPopupMenu popup = new JPopupMenu();
JMenuItem menuItem = new JMenuItem("A popup menu item");
menuItem.setForeground( new Color(255, 0, 0, 50) );
popup.add( menuItem );

代码示例来源:origin: Exslims/MercuryTrade

public JMenuItem getMenuItem(String text) {
  JMenuItem menuItem = new JMenuItem(text);
  menuItem.setFont(REGULAR_FONT.deriveFont(scale * 16f));
  menuItem.setForeground(AppThemeColor.TEXT_DEFAULT);
  return menuItem;
}

代码示例来源:origin: edu.illinois.lis/indri

/**
 * Make a menu item with appropriate colors and <code>this</end> as its listener. 
 * @param label The label for the menu item
 * @return The menu item
 */
private JMenuItem makeMenuItem(String label) {
JMenuItem item     = new JMenuItem(label);
item.setForeground(navyBlue);
item.setBackground(lightYellow);
item.addActionListener(this);
return item;
}

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

@ScriptFunction
@Override
public void setForeground(Color aValue) {
  super.setForeground(aValue);
}

代码示例来源:origin: com.coherentlogic.coherent.data-model/demo-application

protected void addAPIMenuItem (JMenu helpMenu) {
  JMenuItem apiJavadocs = new JMenuItem("API Javadocs");
  apiJavadocs.setForeground(Color.blue);
  helpMenu.add(apiJavadocs);
  apiJavadocs.addActionListener(
    new ActionListener () {
      @Override
      public void actionPerformed(ActionEvent actionEvent) {
        // This is for tracking purposes and will direct the user
        // to http://coherentlogic.com/fredJavaDoc/
        try {
          AboutDialog.open(javaDocDestination);
        } catch (URISyntaxException uriSyntaxException) {
          throw new InvalidURIException(
            "Unable to open the destination: " +
              javaDocDestination,
            uriSyntaxException
          );
        }
      }
    }
  );
}

代码示例来源:origin: net.preibisch/multiview-reconstruction

@Override
public void actionPerformed( final ActionEvent e )
{
  for ( int i = 0; i < items.length; ++i )
  {
    if ( i == myState )
    {
      items[ i ].setForeground( Color.RED );
      items[ i ].setFocusable( false );
    }
    else
      items[ i ].setForeground( Color.GRAY );
  }
  changer.setSelectedState( myState );
  this.hasMouseFocusWaiting = false;
}

代码示例来源:origin: GoldenGnu/jeveassets

private static void createMenuItem(final JPopupMenu jPopupMenu, final String text, final String toolTipText, final Icon icon) {
  JMenuItem jMenuItem = new JMenuItem(text);
  jMenuItem.setToolTipText(toolTipText);
  jMenuItem.setEnabled(false);
  jMenuItem.setDisabledIcon(icon);
  jMenuItem.setForeground(Color.BLACK);
  jMenuItem.setHorizontalAlignment(SwingConstants.RIGHT);
  jPopupMenu.add(jMenuItem);
}

代码示例来源:origin: GoldenGnu/jeveassets

public static void createDefault(final JPopupMenu jPopupMenu) {
  JMenuItem jMenuItem;
  jPopupMenu.addSeparator();
  jMenuItem = new JMenuItem(GuiShared.get().selectionTitle());
  jMenuItem.setDisabledIcon(Images.DIALOG_ABOUT.getIcon());
  jMenuItem.setEnabled(false);
  jMenuItem.setForeground(Color.BLACK);
  jPopupMenu.add(jMenuItem);
  JPanel jSpacePanel = new JPanel();
  jSpacePanel.setOpaque(false);
  jSpacePanel.setMinimumSize(new Dimension(50, 5));
  jSpacePanel.setPreferredSize(new Dimension(50, 5));
  jSpacePanel.setMaximumSize(new Dimension(50, 5));
  jPopupMenu.add(jSpacePanel);
}

代码示例来源:origin: stackoverflow.com

mHelp.setForeground(Color.DARK_GRAY);
mHelp.setFont(new Font("Verdana", Font.PLAIN,12));
mCredits.setOpaque(false);
mCredits.setForeground(Color.DARK_GRAY);
mCredits.setFont(new Font("Verdana", Font.PLAIN,12));
mExit.setOpaque(false);
mExit.setForeground(Color.DARK_GRAY);
mExit.setFont(new Font("Verdana", Font.PLAIN,12));

代码示例来源:origin: com.github.arnabk/pgslookandfeel

protected void paintText(Graphics g, JMenuItem c, Rectangle textRect, String text) {
    PgsUtils.installAntialiasing(g);
    if (c.getParent() instanceof JMenuBar) {
      c.setForeground(UIManager.getColor("MenuBarMenu.foreground"));
      selectionForeground = UIManager.getColor("MenuBarMenu.foreground");
    }
    super.paintText(g, c, textRect, text);
    PgsUtils.uninstallAntialiasing(g);
  }
}

代码示例来源:origin: atarw/material-ui-swing

@Override
public void installUI (JComponent c) {
  super.installUI (c);
  JMenuItem menuItem = (JMenuItem) c;
  menuItem.setFont (UIManager.getFont ("MenuItem.font"));
  menuItem.setBackground (UIManager.getColor ("MenuItem.background"));
  menuItem.setForeground (UIManager.getColor ("MenuItem.foreground"));
  menuItem.setHorizontalAlignment (SwingConstants.LEFT);
  menuItem.setVerticalAlignment (SwingConstants.CENTER);
  menuItem.setBorder (UIManager.getBorder ("MenuItem.border"));
}

代码示例来源:origin: abc9070410/JComicDownloader

private JMenuItem getMenuItem(String text, String enText, Icon icon) {
  text = Common.getStringUsingDefaultLanguage(text, enText); // 使用預設語言
  JMenuItem menuItem = new JMenuItem(text, icon);
  menuItem.addActionListener(this);
  if (SetUp.getUsingBackgroundPicOfMainFrame()) { // 若設定為透明,就用預定字體。
    menuItem.setForeground(SetUp.getMainFrameMenuItemDefaultColor());
    //menuItem.addMouseListener( this );
    //menuItem.setOpaque( true );
  }
  if (SetUp.getSkinClassName().matches(".*napkin.*")) {
    // 因為napkin的預設字型不太清楚,所以用選定字型
    menuItem.setFont(SetUp.getDefaultFont(- 3));
  }
  return menuItem;
}

代码示例来源: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: net.preibisch/multiview-reconstruction

@Override
public void menuSelected( MenuEvent e )
{
  showDistanceHist.removeAll();
  final SpimData2 spimData = (SpimData2)panel.getSpimData();
  final ArrayList< ViewId > views = new ArrayList<>();
  views.addAll( ApplyTransformationPopup.getSelectedViews( panel ) );
  // filter not present ViewIds
  SpimData2.filterMissingViews( panel.getSpimData(), views );
  final String[] labels = InterestPointTools.getAllInterestPointLabels( spimData, views );
  if ( labels.length == 0 )
  {
    JMenuItem item = new JMenuItem( "No interest points found" );
    item.setForeground( Color.GRAY );
    showDistanceHist.add( item );
  }
  else
  {
    for ( int i = 0; i < labels.length; ++i )
    {
      JMenuItem item = new JMenuItem( labels[ i ] );
      item.addActionListener( new HistogramListener( spimData, views, InterestPointTools.getSelectedLabel( labels, i ), i ) );
      showDistanceHist.add( item );
    }
  }
}

代码示例来源:origin: org.biojava.thirdparty/forester

static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
  label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
  if ( !configuration.isUseNativeUI() ) {
    label.setBackground( configuration.getGuiMenuBackgroundColor() );
    label.setForeground( configuration.getGuiMenuTextColor() );
    label.setOpaque( true );
  }
  label.setSelected( false );
  label.setEnabled( false );
  return label;
}

代码示例来源:origin: net.preibisch/multiview-reconstruction

@Override
public void menuSelected( MenuEvent e )
{
  assignExistingPSF.removeAll();
  final SpimData2 spimData = (SpimData2)panel.getSpimData();
  final ArrayList< ViewId > psfs = PSF_Assign.viewsWithUniquePSFs( spimData.getPointSpreadFunctions() );
  final String[] psfTitles = PSF_Assign.assemblePSFs( psfs, spimData.getPointSpreadFunctions().getPointSpreadFunctions() );
  if ( psfTitles.length == 0 )
  {
    JMenuItem item = new JMenuItem( "No PSFs found" );
    item.setForeground( Color.GRAY );
    assignExistingPSF.add( item );
  }
  else
  {
    for ( int i = 0; i < psfTitles.length; ++i )
    {
      JMenuItem item = new JMenuItem( psfTitles[ i ] );
      item.addActionListener( new AssignPSF( psfs.get( i ) ) );
      assignExistingPSF.add( item );
    }
  }
}

代码示例来源:origin: net.preibisch/multiview-reconstruction

item.setForeground( Color.RED );
else
  item.setForeground( Color.GRAY );

代码示例来源:origin: org.biojava.thirdparty/forester

void customizeJMenuItem( final JMenuItem jmi ) {
  if ( jmi != null ) {
    jmi.setFont( MainFrame.menu_font );
    if ( !getConfiguration().isUseNativeUI() ) {
      jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
      jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
    }
    jmi.addActionListener( this );
  }
}

代码示例来源:origin: org.biojava.thirdparty/forester

JMenuItem customizeJMenuItem( final JMenuItem jmi ) {
  if ( jmi != null ) {
    jmi.setFont( MainFrame.menu_font );
    if ( !getConfiguration().isUseNativeUI() ) {
      jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
      jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
    }
    jmi.addActionListener( this );
  }
  return jmi;
}

相关文章

JMenuItem类方法