List of utility methods to do Swing Menu Item
JMenuItem | makeMenuItem(String s, ActionListener listener) make Menu Item final JMenuItem item = new JMenuItem(s); item.setBackground(BLUE8); item.setForeground(BLUE3); item.setFont(MEDIUM); item.addActionListener(listener); return item; |
JMenuItem | makeMenuItem(URL iconURL, String text, ActionListener listener) make Menu Item JMenuItem item = new JMenuItem(text); item.addActionListener(listener); if (iconURL != null) { item.setIcon(new ImageIcon(iconURL, text)); return item; |
JMenuItem | newMenuItem(String name, KeyStroke keyStroke, final Runnable runnable) new Menu Item JMenuItem menuItem = new JMenuItem(name); menuItem.setAccelerator(keyStroke); menuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { java.awt.EventQueue.invokeLater(runnable); }); ... |
void | paintMenuItemBackground(Graphics g, Component c) Paints the background for a menu item (or a menu or separator in a menu). Graphics2D g2d = (Graphics2D) g; Paint menuItemBGPaint = (Paint) UIManager.get("OfficeLnF.MenuItemIconAreaPaint"); g2d.setPaint(menuItemBGPaint); int width = c.getWidth(); int mainWidth = width - LEFT_EDGE_WIDTH; int height = c.getHeight(); if (c.getComponentOrientation().isLeftToRight()) { g.fillRect(0, 0, LEFT_EDGE_WIDTH, height); ... |
JMenuItem | userManualMenuItem() user Manual Menu Item JMenuItem menu_item = new JMenuItem("User Manual"); menu_item.getAccessibleContext().setAccessibleDescription("User Manual"); menu_item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { JOptionPane.showMessageDialog(null, "go to http://zae.sourceforge.net"); }); return menu_item; ... |