Java Code Examples for javax.swing.JMenuItem#setBackground()
The following examples show how to use
javax.swing.JMenuItem#setBackground() .
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: MenuFactory.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 2
Source File: JPlagCreator.java From jplag with GNU General Public License v3.0 | 5 votes |
/** * This method initializes jMenuItem * * @return javax.swing.JMenuItem */ public static JMenuItem createJMenuItem(String text) { JMenuItem jMenuItem = new JMenuItem(); jMenuItem.setText(text); jMenuItem.setFont(JPlagCreator.SYSTEM_FONT); jMenuItem.setBackground(JPlagCreator.SYSTEMCOLOR); return jMenuItem; }
Example 3
Source File: FollowButton.java From saros with GNU General Public License v2.0 | 5 votes |
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 4
Source File: FollowButton.java From saros with GNU General Public License v2.0 | 5 votes |
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 5
Source File: ConnectButton.java From saros with GNU General Public License v2.0 | 5 votes |
private JMenuItem getPreconfiguredMenuItem(String text) { JMenuItem jMenuItem = new JBMenuItem(text); jMenuItem.setForeground(FOREGROUND_COLOR); jMenuItem.setBackground(BACKGROUND_COLOR); return jMenuItem; }
Example 6
Source File: RosterDialog.java From Spark with Apache License 2.0 | 4 votes |
/** * 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); } } }