Java Code Examples for javax.swing.JMenuItem#setForeground()

The following examples show how to use javax.swing.JMenuItem#setForeground() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoDownloadWindow.java    From xdm with GNU General Public License v2.0 6 votes vote down vote up
private void createPopup() {
	pop = new JPopupMenu();
	pop.setBackground(ColorResource.getDarkerBgColor());
	JMenu dl = new JMenu(StringResource.get("ND_DOWNLOAD_LATER"));
	dl.setForeground(Color.WHITE);
	dl.setBorder(new EmptyBorder(getScaledInt(5), getScaledInt(5), getScaledInt(5), getScaledInt(5)));
	dl.addActionListener(this);
	dl.setBackground(ColorResource.getDarkerBgColor());
	dl.setBorderPainted(false);
	// dl.setBackground(C);
	pop.add(dl);

	createQueueItems(dl);

	JMenuItem ig = new JMenuItem(StringResource.get("ND_IGNORE_URL"));
	ig.setName("IGNORE_URL");
	ig.setForeground(Color.WHITE);
	ig.addActionListener(this);
	pop.add(ig);
	pop.setInvoker(btnMore);
}
 
Example 2
Source File: NewDownloadWindow.java    From xdm with GNU General Public License v2.0 6 votes vote down vote up
private void createPopup() {
	pop = new JPopupMenu();
	pop.setBackground(ColorResource.getDarkerBgColor());
	JMenu dl = new JMenu(StringResource.get("ND_DOWNLOAD_LATER"));
	dl.setForeground(Color.WHITE);
	dl.setBorder(new EmptyBorder(getScaledInt(5), getScaledInt(5), getScaledInt(5), getScaledInt(5)));
	dl.addActionListener(this);
	dl.setBackground(ColorResource.getDarkerBgColor());
	dl.setBorderPainted(false);
	// dl.setBackground(C);
	pop.add(dl);

	createQueueItems(dl);

	JMenuItem ig = new JMenuItem(StringResource.get("ND_IGNORE_URL"));
	ig.setName("IGNORE_URL");
	ig.setForeground(Color.WHITE);
	ig.addActionListener(this);
	pop.add(ig);
	pop.setInvoker(btnMore);
}
 
Example 3
Source File: SettingsPage.java    From xdm with GNU General Public License v2.0 6 votes vote down vote up
private void showMoveQPopup(JButton btn) {
	int index = qList.getSelectedIndex();
	if (index < 0) {
		return;
	}
	DownloadQueue q = queueModel.get(index);
	String qid = q.getQueueId();
	if (qid == null)
		return;
	JPopupMenu popupMenu = new JPopupMenu();
	for (int i = 0; i < QueueManager.getInstance().getQueueList().size(); i++) {
		DownloadQueue tq = QueueManager.getInstance().getQueueList().get(i);
		if (qid.equals(tq.getQueueId())) {
			continue;
		}
		JMenuItem item = new JMenuItem(tq.getName());
		item.setName("Q_MOVE_TO:" + tq.getQueueId());
		item.addActionListener(this);
		item.setForeground(Color.WHITE);
		item.setFont(FontResource.getNormalFont());
		popupMenu.add(item);
	}
	popupMenu.setInvoker(btn);
	popupMenu.show(btn, 0, btn.getHeight());
}
 
Example 4
Source File: VideoDownloadWindow.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
private void createQueueItems(JMenuItem queueMenuItem) {
	ArrayList<DownloadQueue> queues = XDMApp.getInstance().getQueueList();
	for (int i = 0; i < queues.size(); i++) {
		DownloadQueue q = queues.get(i);
		JMenuItem mItem = new JMenuItem(q.getName().length() < 1 ? "Default queue" : q.getName());
		mItem.setName("QUEUE:" + q.getQueueId());
		mItem.setForeground(Color.WHITE);
		mItem.addActionListener(this);
		queueMenuItem.add(mItem);
	}
}
 
Example 5
Source File: MainWindow.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
private void loadStopQueueMenu(JMenu menu) {
	menu.removeAll();
	ArrayList<DownloadQueue> queues = XDMApp.getInstance().getQueueList();
	for (int i = 0; i < queues.size(); i++) {
		DownloadQueue q = queues.get(i);
		if (q.isRunning()) {
			JMenuItem mitem = new JMenuItem(q.getName());
			mitem.setForeground(ColorResource.getLightFontColor());
			mitem.setName("STOP:" + q.getQueueId());
			mitem.addActionListener(this);
			menu.add(mitem);
		}
	}
}
 
Example 6
Source File: MainWindow.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
private void loadStartQueueMenu(JMenu menu) {
	menu.removeAll();
	ArrayList<DownloadQueue> queues = XDMApp.getInstance().getQueueList();
	for (int i = 0; i < queues.size(); i++) {
		DownloadQueue q = queues.get(i);
		if (!q.isRunning()) {
			JMenuItem mitem = new JMenuItem(q.getName());
			mitem.setForeground(ColorResource.getLightFontColor());
			mitem.setName("START:" + q.getQueueId());
			mitem.addActionListener(this);
			menu.add(mitem);
		}
	}
}
 
Example 7
Source File: NewDownloadWindow.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
private void createQueueItems(JMenuItem queueMenuItem) {
	ArrayList<DownloadQueue> queues = XDMApp.getInstance().getQueueList();
	for (int i = 0; i < queues.size(); i++) {
		DownloadQueue q = queues.get(i);
		JMenuItem mItem = new JMenuItem(q.getName().length() < 1 ? "Default queue" : q.getName());
		mItem.setName("QUEUE:" + q.getQueueId());
		mItem.setForeground(Color.WHITE);
		mItem.addActionListener(this);
		queueMenuItem.add(mItem);
	}
}
 
Example 8
Source File: ShapeSet.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
private static void addColoredItem (JComponent top,
                                    JMenuItem item,
                                    Color color)
{
    if (color != null) {
        item.setForeground(color);
    } else {
        item.setForeground(Color.black);
    }

    top.add(item);
}
 
Example 9
Source File: ConnectButton.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
private JMenuItem getPreconfiguredMenuItem(String text) {
  JMenuItem jMenuItem = new JBMenuItem(text);

  jMenuItem.setForeground(FOREGROUND_COLOR);
  jMenuItem.setBackground(BACKGROUND_COLOR);

  return jMenuItem;
}
 
Example 10
Source File: PopUpMenu.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public PopUpMenu(final SettlementWindow swindow, final Unit unit){
    	this.unit = unit;
    	this.settlement = swindow.getMapPanel().getSettlement();
        this.desktop = (MainDesktopPane) swindow.getDesktop();

        UIResource res = new BorderUIResource.LineBorderUIResource(Color.orange);
        UIManager.put("PopupMenu.border", res);

        //force to the Heavyweight Component or able for AWT Components
        this.setLightWeightPopupEnabled(false);

    	itemOne = new JMenuItem(Msg.getString("PopUpUnitMenu.itemOne"));
        itemOne.setForeground(new Color(139,69,19));

       	add(itemOne);

       	buildItemOne(unit);
    
//     // Determine what the GraphicsDevice can support.
//        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
//        GraphicsDevice gd = ge.getDefaultScreenDevice();
//        boolean isPerPixelTranslucencySupported =
//            gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);
//
//        //If translucent windows aren't supported, exit.
//        if (!isPerPixelTranslucencySupported) {
//            System.out.println(
//                "Per-pixel translucency is not supported");
//                System.exit(0);
//        }
       

    }
 
Example 11
Source File: MenuFactory.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
private static void setMenuProperties(JMenuItem menuItem) {
	menuItem.setOpaque(false);
	menuItem.setBackground(ColorPalette.DARK_BACKGROUND_COLOR);
	menuItem.setForeground(ColorPalette.FOREGROUND_COLOR);
	menuItem.setFont(Fonts.FONT);
	menuItem.setCursor(Cursors.CURSOR);
}
 
Example 12
Source File: ShapeSet.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void addColoredItem (JComponent top,
                                    JMenuItem item,
                                    Color color)
{
    if (color != null) {
        item.setForeground(color);
    } else {
        item.setForeground(Color.black);
    }

    top.add(item);
}
 
Example 13
Source File: FollowButton.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
private void createMenu() {
  popupMenu = new JBPopupMenu();

  popupMenu.setForeground(FOREGROUND_COLOR);
  popupMenu.setBackground(BACKGROUND_COLOR);

  menuItemPrefix = Messages.FollowButton_user_entry_prefix;

  ISarosSession currentSession = session;
  FollowModeManager currentFollowModeManager = followModeManager;

  if (currentSession == null || currentFollowModeManager == null) {
    return;
  }

  for (User user : currentSession.getRemoteUsers()) {
    JMenuItem menuItem = createItemForUser(user);
    popupMenu.add(menuItem);
  }

  popupMenu.addSeparator();

  JMenuItem leaveItem = new JBMenuItem(Messages.FollowButton_leave_follow_mode_entry);

  leaveItem.setForeground(FOREGROUND_COLOR);
  leaveItem.setBackground(BACKGROUND_COLOR);

  leaveItem.addActionListener(e -> followModeAction.execute(session, followModeManager, null));
  leaveItem.setEnabled(currentFollowModeManager.getFollowedUser() != null);

  popupMenu.add(leaveItem);
}
 
Example 14
Source File: FollowButton.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
private JMenuItem createItemForUser(User user) {
  String userName = CoreUtils.determineUserDisplayName(user);
  String userNameShort = userName;
  int index = userNameShort.indexOf("@");
  if (index > -1) {
    userNameShort = userNameShort.substring(0, index);
  }

  JMenuItem menuItem = new JBMenuItem(menuItemPrefix + " " + userNameShort);

  menuItem.setForeground(FOREGROUND_COLOR);
  menuItem.setBackground(BACKGROUND_COLOR);

  FollowModeManager currentFollowModeManager = followModeManager;

  User currentlyFollowedUser = null;

  if (currentFollowModeManager != null) {
    currentlyFollowedUser = currentFollowModeManager.getFollowedUser();
  }

  if (currentlyFollowedUser != null) {
    String currentUserName = CoreUtils.determineUserDisplayName(currentlyFollowedUser);
    if (currentUserName.equalsIgnoreCase(userNameShort)) {
      menuItem.setEnabled(false);
    }
  }

  menuItem.setActionCommand(userName);
  menuItem.addActionListener(
      e -> followModeAction.execute(session, followModeManager, e.getActionCommand()));

  return menuItem;
}
 
Example 15
Source File: RosterDialog.java    From Spark with Apache License 2.0 4 votes vote down vote up
/**
    * Creates a Popupdialog above the Search Button displaying matching
    * Contacts
    * 
    * @param byname
    *            , the Searchname, atleast 5 Chars long
    * @param event
    *            , the MouseEvent which triggered it
    * @throws XMPPException
    * @throws InterruptedException 
    */
   public void searchForContact(String byname, MouseEvent event)
           throws XMPPException, SmackException.NotConnectedException, SmackException.NoResponseException, InterruptedException
   {

   	UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
   	
if (byname.contains("@")) {
    byname = byname.substring(0, byname.indexOf("@"));
}

if (byname.length() <= 1) {
    JOptionPane.showMessageDialog(jidField,
	    Res.getString("message.search.input.short"),
	    Res.getString("title.notification"),
	    JOptionPane.ERROR_MESSAGE);

} else {

    JPopupMenu popup = new JPopupMenu();
    JMenuItem header = new JMenuItem(
	    Res.getString("group.search.results") + ":");
    header.setBackground(UIManager.getColor("List.selectionBackground"));
    header.setForeground(Color.red);
    popup.add(header);

    for (DomainBareJid search : _usersearchservice) {

	ReportedData data;
	UserSearchManager usersearchManager = new UserSearchManager(
		SparkManager.getConnection());

	Form f = usersearchManager.getSearchForm(search);

	Form answer = f.createAnswerForm();
	answer.setAnswer("Name", true);
	answer.setAnswer("Email", true);
	answer.setAnswer("Username", true);
	answer.setAnswer("search", byname);

	data = usersearchManager.getSearchResults(answer, search);

	ArrayList<String> columnnames = new ArrayList<>();
	for ( ReportedData.Column column : data.getColumns() ) {
	    String label = column.getLabel();
	    columnnames.add(label);
	}

	for (ReportedData.Row row : data.getRows() ) {
	    if (!row.getValues(columnnames.get(0)).isEmpty()) {
		String s = row.getValues(columnnames.get(0))
			.get(0).toString();
		final JMenuItem item = new JMenuItem(s);
		popup.add(item);
		item.addActionListener( e -> {
           jidField.setText(item.getText());
           nicknameField.setText(XmppStringUtils
               .parseLocalpart(item.getText()));
           } );
	    }

	}
    }

    if (popup.getComponentCount() > 2) {
	popup.setVisible(true);
	popup.show(_searchForName, event.getX(), event.getY());
    } else if (popup.getComponentCount() == 2) {
	jidField.setText(((JMenuItem) popup.getComponent(1)).getText());
	nicknameField.setText(XmppStringUtils.parseLocalpart(((JMenuItem) popup
		.getComponent(1)).getText()));
    } else {
	JOptionPane.showMessageDialog(jidField,
		Res.getString("message.no.results.found"),
		Res.getString("title.notification"),
		JOptionPane.ERROR_MESSAGE);
    }
}
   }
 
Example 16
Source File: PopUpUnitMenu.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public PopUpUnitMenu(final SettlementWindow swindow, final Unit unit){
    	this.unit = unit;
    	desktop = swindow.getDesktop();
    	this.settlement = swindow.getMapPanel().getSettlement();
      
        UIResource res = new BorderUIResource.LineBorderUIResource(Color.orange);
        UIManager.put("PopupMenu.border", res);
        //force to the Heavyweight Component or able for AWT Components
        this.setLightWeightPopupEnabled(false); 
             
    	itemOne = new JMenuItem(Msg.getString("PopUpUnitMenu.itemOne"));
        itemTwo = new JMenuItem(Msg.getString("PopUpUnitMenu.itemTwo"));  
        itemThree = new JMenuItem(Msg.getString("PopUpUnitMenu.itemThree"));
        itemOne.setForeground(new Color(139,69,19));
        itemTwo.setForeground(new Color(139,69,19));
        itemThree.setForeground(new Color(139,69,19));
        
        if (unit instanceof Person) {
        	add(itemTwo);
        	buildItemTwo(unit);
        }
        
        else if (unit instanceof Vehicle) {
        	add(itemOne);
        	add(itemTwo);
        	add(itemThree);
        	buildItemOne(unit);
            buildItemTwo(unit);
            buildItemThree(unit);
        }
        else {
            add(itemOne);
        	add(itemTwo);
        	buildItemOne(unit);
            buildItemTwo(unit);
        }

     // Determine what the GraphicsDevice can support.
//        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
//        GraphicsDevice gd = ge.getDefaultScreenDevice();
//        boolean isPerPixelTranslucencySupported = 
//            gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);
//
//        //If translucent windows aren't supported, exit.
//        if (!isPerPixelTranslucencySupported) {
//            System.out.println(
//                "Per-pixel translucency is not supported");
//                System.exit(0);
//        }

    }
 
Example 17
Source File: ProfilerPopupMenu.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public JMenuItem add(JMenuItem menuItem) {
    if (forceBackground && !UIUtils.isOracleLookAndFeel()) menuItem.setOpaque(false);
    if (forceBackground && !UIUtils.isNimbusLookAndFeel()) menuItem.setForeground(getForeground());
    return super.add(menuItem);
}