Example usage for javax.swing JMenuItem getFont

List of usage examples for javax.swing JMenuItem getFont

Introduction

In this page you can find the example usage for javax.swing JMenuItem getFont.

Prototype

@Transient
public Font getFont() 

Source Link

Document

Gets the font of this component.

Usage

From source file:net.sf.jabref.gui.RightClickMenu.java

/** Sets the font and icon to be used, depending on the group */
private void setGroupFontAndIcon(JMenuItem menuItem, AbstractGroup group) {
    if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_DYNAMIC)) {
        menuItem.setFont(menuItem.getFont().deriveFont(group.isDynamic() ? Font.ITALIC : Font.PLAIN));
    }//from w  w w. j  a  v a  2  s .c  o  m
    if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_ICONS)) {
        switch (group.getHierarchicalContext()) {
        case INCLUDING:
            menuItem.setIcon(IconTheme.JabRefIcon.GROUP_INCLUDING.getSmallIcon());
            break;
        case REFINING:
            menuItem.setIcon(IconTheme.JabRefIcon.GROUP_REFINING.getSmallIcon());
            break;
        default:
            menuItem.setIcon(IconTheme.JabRefIcon.GROUP_REGULAR.getSmallIcon());
            break;
        }
    }
}

From source file:de.huxhorn.lilith.swing.ViewActions.java

private void initPopup() {
    if (logger.isDebugEnabled())
        logger.debug("initPopup()");
    popup = new JPopupMenu();
    JMenuItem showUnfilteredMenuItem = new JMenuItem(showUnfilteredEventAction);
    Font f = showUnfilteredMenuItem.getFont();
    Font boldFont = f.deriveFont(Font.BOLD);
    showUnfilteredMenuItem.setFont(boldFont);

    popup.add(showUnfilteredMenuItem);//  www . j  a  v  a 2s  .  com

    filterPopupMenu = new JMenu("Filter");
    popup.add(filterPopupMenu);
    filterPopupMenu.add(closeFilterAction);
    filterPopupMenu.add(closeOtherFiltersAction);
    filterPopupMenu.add(closeAllFiltersAction);

    popup.addSeparator();
    popup.add(saveConditionMenuAction);
    popup.addSeparator();

    focusPopupMenu = new FocusMenu(mainFrame.getApplicationPreferences());
    excludePopupMenu = new ExcludeMenu(mainFrame.getApplicationPreferences());

    popup.add(focusPopupMenu);
    popup.add(excludePopupMenu);
    popup.addSeparator();

    updateCustomCopyMenu(this.eventWrapper);

    copyPopupMenu = new JMenu("Copy");
    popup.add(copyPopupMenu);
    copyPopupMenu.add(copySelectionAction);
    copyPopupMenu.addSeparator();
    copyPopupMenu.add(copyEventAction);
    copyPopupMenu.addSeparator();
    for (CopyToClipboardAction current : copyLoggingActions) {
        copyPopupMenu.add(current);
    }

    copyPopupMenu.addSeparator();
    for (CopyToClipboardAction current : copyAccessActions) {
        copyPopupMenu.add(current);
    }

    copyPopupMenu.addSeparator();
    copyPopupMenu.add(customCopyPopupMenu);

    sendToPopupMenu = new JMenu("Send to");
    popup.add(sendToPopupMenu);

    popup.add(gotoSourceAction);
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenterTest.java

@Test
public final void testFormUtilities() {
    JFrame frame = new JFrame();
    Font theFont = new Font("Arial", Font.BOLD, 14);
    javax.swing.JMenuBar mnuMain = new JMenuBar();
    JMenu menu1 = new JMenu();
    JMenuItem menu1_1 = new JMenuItem();
    JMenuItem menu1_2 = new JMenuItem();
    JMenuItem menu1_3 = new JMenuItem();
    menu1.add(menu1_1);//from   w  w  w . jav a2 s . c o  m
    menu1.add(menu1_2);
    menu1.add(menu1_3);
    JMenu menu2 = new JMenu();
    JMenuItem menu2_1 = new JMenuItem();
    JMenuItem menu2_2 = new JMenuItem();
    JMenuItem menu2_3 = new JMenuItem();
    menu1.add(menu2_1);
    menu1.add(menu2_2);
    menu1.add(menu2_3);
    JMenu menu3 = new JMenu();
    JMenuItem menu3_1 = new JMenuItem();
    JMenuItem menu3_2 = new JMenuItem();
    JMenuItem menu3_3 = new JMenuItem();
    menu1.add(menu3_1);
    menu1.add(menu3_2);
    menu1.add(menu3_3);
    frame.setJMenuBar(mnuMain);
    mnuMain.add(menu1);
    mnuMain.add(menu2);
    mnuMain.add(menu3);

    JPanel pnlTest = new JPanel();
    pnlTest.setBorder(javax.swing.BorderFactory.createTitledBorder("Test Border"));
    frame.add(pnlTest);
    JLabel label1 = new JLabel();
    JTextField text1 = new JTextField();
    pnlTest.add(label1);
    pnlTest.add(text1);
    JLabel label2 = new JLabel();
    JTextField text2 = new JTextField();
    frame.add(label2);
    frame.add(text2);

    assertFalse(menu1.getFont().equals(theFont));
    assertFalse(menu2.getFont().equals(theFont));
    assertFalse(menu3.getFont().equals(theFont));
    assertFalse(menu1_1.getFont().equals(theFont));
    assertFalse(menu1_2.getFont().equals(theFont));
    assertFalse(menu1_3.getFont().equals(theFont));
    assertFalse(menu2_1.getFont().equals(theFont));
    assertFalse(menu2_2.getFont().equals(theFont));
    assertFalse(menu2_3.getFont().equals(theFont));
    assertFalse(menu3_1.getFont().equals(theFont));
    assertFalse(menu3_2.getFont().equals(theFont));
    assertFalse(menu3_3.getFont().equals(theFont));
    assertFalse(pnlTest.getFont().equals(theFont));
    assertFalse(label1.getFont().equals(theFont));
    assertFalse(label2.getFont().equals(theFont));
    assertFalse(text1.getFont().equals(theFont));
    assertFalse(text2.getFont().equals(theFont));

    FormUtilities.setFormFont(frame, theFont);

    assertTrue(menu1.getFont().equals(theFont));
    assertTrue(menu2.getFont().equals(theFont));
    assertTrue(menu3.getFont().equals(theFont));
    assertTrue(menu1_1.getFont().equals(theFont));
    assertTrue(menu1_2.getFont().equals(theFont));
    assertTrue(menu1_3.getFont().equals(theFont));
    assertTrue(menu2_1.getFont().equals(theFont));
    assertTrue(menu2_2.getFont().equals(theFont));
    assertTrue(menu2_3.getFont().equals(theFont));
    assertTrue(menu3_1.getFont().equals(theFont));
    assertTrue(menu3_2.getFont().equals(theFont));
    assertTrue(menu3_3.getFont().equals(theFont));
    assertTrue(pnlTest.getFont().equals(theFont));
    assertTrue(label1.getFont().equals(theFont));
    assertTrue(label2.getFont().equals(theFont));
    assertTrue(text1.getFont().equals(theFont));
    assertTrue(text2.getFont().equals(theFont));
}