Example usage for java.awt CheckboxMenuItem setFont

List of usage examples for java.awt CheckboxMenuItem setFont

Introduction

In this page you can find the example usage for java.awt CheckboxMenuItem 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: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 ww  .j  a  v a2s.  c  o  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;
}