Here you can find the source of createMenuItem(final String label, final String accessibleDescription, final ActionListener actionListener)
Parameter | Description |
---|---|
label | the label text for the menu item. |
accessibleDescription | the description of the menu item for tool tips, etc. |
actionListener | the listener for when the menu item is selected. |
public static JMenuItem createMenuItem(final String label, final String accessibleDescription, final ActionListener actionListener)
//package com.java2s; import java.awt.event.ActionListener; import javax.swing.JMenuItem; public class Main { /**/* w w w . jav a 2s. c o m*/ * Create a menu item. * * @param label the label text for the menu item. * @param accessibleDescription the description of the menu item for tool tips, etc. * @param actionListener the listener for when the menu item is selected. * @return a menu item. */ public static JMenuItem createMenuItem(final String label, final String accessibleDescription, final ActionListener actionListener) { JMenuItem menuItem = new JMenuItem(label); menuItem.getAccessibleContext().setAccessibleDescription(accessibleDescription); menuItem.addActionListener(actionListener); return menuItem; } /** * Create a menu item. * * @param label the label text for the menu item. * @param mnemonic the mnemonic for the menu item accelerator. * @param accessibleDescription the description of the menu item for tool tips, etc. * @param actionListener the listener for when the menu item is selected. * @return a menu item. */ public static JMenuItem createMenuItem(final String label, final String mnemonic, final String accessibleDescription, final ActionListener actionListener) { JMenuItem menuItem = new JMenuItem(label); menuItem.setMnemonic(mnemonic.charAt(0)); menuItem.getAccessibleContext().setAccessibleDescription(accessibleDescription); menuItem.addActionListener(actionListener); return menuItem; } }