Java Swing Menu Item makeMenuItem(String s, ActionListener listener)

Here you can find the source of makeMenuItem(String s, ActionListener listener)

Description

make Menu Item

License

Apache License

Declaration

public static JMenuItem makeMenuItem(String s, ActionListener listener) 

Method Source Code

//package com.java2s;
/*/*from  w w  w. j av  a  2s.c o m*/
 * Copyright (c) 2015 IBM Corporation and others.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * You may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;

public class Main {
    public static final Font MEDIUM = new Font("Inconsolata, Arial", Font.PLAIN, 12);
    public static final Color BLUE3 = new Color(0, 178, 239);
    public static final Color BLUE8 = new Color(0, 25, 52);

    public static JMenuItem makeMenuItem(String s, ActionListener listener) {
        final JMenuItem item = new JMenuItem(s);
        item.setBackground(BLUE8);
        item.setForeground(BLUE3);
        item.setFont(MEDIUM);
        item.addActionListener(listener);
        return item;
    }
}

Related

  1. makeCheckboxMenuItem(String label, final Object object, final String property, final Object arg)
  2. makeMenu(String name, List menuItems)
  3. makeMenuItem(Icon icon, Icon rollover, String menu_cmd, boolean is_toggle, int mnemonic, int accel)
  4. makeMenuItem(Icon icon, Icon rollover, String menu_cmd, boolean is_toggle, int mnemonic, int accel)
  5. makeMenuItem(String label, final Object object, final String methodName)
  6. makeMenuItem(URL iconURL, String text, ActionListener listener)
  7. newMenuItem(String name, KeyStroke keyStroke, final Runnable runnable)
  8. paintMenuItemBackground(Graphics g, Component c)
  9. userManualMenuItem()