Example usage for java.awt MenuItem setFont

List of usage examples for java.awt MenuItem setFont

Introduction

In this page you can find the example usage for java.awt MenuItem setFont.

Prototype

public void setFont(Font f) 

Source Link

Document

Sets the font to be used for this menu component to the specified font.

Usage

From source file:de.tbuchloh.kiskis.gui.MainFrame.java

/**
 * @see de.tbuchloh.kiskis.gui.systray.IMainFrame#getPopupMenu()
 *///from ww w  .j  av  a2  s.c om
@Override
public PopupMenu getPopupMenu() {
    final PopupMenu popup = new PopupMenu();
    for (final Action act : _main.getPopupActions()) {
        if (act == null) {
            popup.addSeparator();
        } else {
            final MenuItem mi = new MenuItem((String) act.getValue(Action.NAME));
            mi.setEnabled(act.isEnabled());
            mi.addActionListener(act);
            mi.setFont(new Font("Arial", Font.BOLD, 12));
            popup.add(mi);
        }
    }
    return popup;
}

From source file:jatoo.app.App.java

private PopupMenu getTrayIconPopup() {

    MenuItem openItem = new MenuItem(getText("popup.open") + " " + getTitle());
    openItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            show();//from w w  w  .  j a  v  a  2 s  .  co  m
        }
    });

    MenuItem hideItem = new MenuItem(getText("popup.hide") + " " + getTitle());
    hideItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            hide();
        }
    });

    CheckboxMenuItem hideWhenMinimizedItem = new CheckboxMenuItem(getText("popup.hide_when_minimized"),
            isHideWhenMinimized());
    hideWhenMinimizedItem.addItemListener(new ItemListener() {
        public void itemStateChanged(final ItemEvent e) {
            setHideWhenMinimized(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    MenuItem sendToBackItem = new MenuItem(getText("popup.send_to_back"));
    sendToBackItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            sendToBack();
        }
    });

    MenuItem closeItem = new MenuItem(getText("popup.close"));
    closeItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            System.exit(0);
        }
    });

    //
    //

    Font font = new JMenuItem().getFont();

    if (font != null) {
        openItem.setFont(font.deriveFont(Font.BOLD));
        hideItem.setFont(font);
        hideWhenMinimizedItem.setFont(font);
        sendToBackItem.setFont(font);
        closeItem.setFont(font);
    }

    //
    // the popup

    PopupMenu popup = new PopupMenu(getTitle());

    popup.add(openItem);
    popup.add(hideItem);
    popup.addSeparator();
    popup.add(hideWhenMinimizedItem);
    popup.addSeparator();
    popup.add(sendToBackItem);
    popup.addSeparator();
    popup.add(closeItem);

    return popup;
}