Example usage for javax.swing JMenuItem setFont

List of usage examples for javax.swing JMenuItem setFont

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.")
public void setFont(Font font) 

Source Link

Document

Sets the font for this component.

Usage

From source file:Main.java

public static void setUpMenuEntries(JMenuItem item) {
    item.setMargin(new Insets(5, 20, 50, 20));
    item.setFont(new Font(APP_FONT, Font.PLAIN, 20));
}

From source file:Main.java

public static void setFont(Container container, Font font) {
    container.setFont(font);/*  w ww. j  av a 2 s  .  c o m*/
    trySetBorderFont(font, container);
    Component[] components = container.getComponents();
    for (Component component : components) {
        component.setFont(font);
        if (component instanceof Container) {
            setFont((Container) component, font);
        }
        trySetBorderFont(font, component);
        if (component instanceof JTable) {
            JTable table = (JTable) component;
            table.getTableHeader().setFont(font);
        }
    }

    if (container instanceof JMenu) {
        JMenu jMenu = (JMenu) container;
        for (int i = 0; i < jMenu.getItemCount(); i++) {
            JMenuItem mi = jMenu.getItem(i);
            mi.setFont(font);
        }
    }
}

From source file:Main.java

static public JMenuItem createJMenuItem(JMenu pMenu, String pText, char pMnemonic, KeyStroke pAccelerator,
        ActionListener pActionListener) throws IllegalArgumentException {
    if (pMenu == null)
        throw new IllegalArgumentException("Menu is missing.");
    if (pText == null)
        throw new IllegalArgumentException("Missing text for menu item.");

    final JMenuItem menuItem = new JMenuItem(pText, pMnemonic);

    if (pAccelerator != null)
        menuItem.setAccelerator(pAccelerator);
    if (pActionListener != null)
        menuItem.addActionListener(pActionListener);
    if (defaultFont != null)
        menuItem.setFont(defaultFont);

    pMenu.add(menuItem);//w w  w . j  av a  2  s.  c om

    return menuItem;
}

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  ww .  ja  v  a 2s  .co  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:es.emergya.ui.gis.FleetControlMapViewer.java

@Override
protected JPopupMenu getContextMenu() {
    JPopupMenu menu = new JPopupMenu();

    menu.setBackground(Color.decode("#E8EDF6"));

    // Ttulo//  w ww . ja v a2s  .co  m
    final JMenuItem titulo = new JMenuItem(i18n.getString("map.menu.titulo.puntoGenerico"));
    titulo.setFont(LogicConstants.deriveBoldFont(10.0f));
    titulo.setBackground(Color.decode("#A4A4A4"));
    titulo.setFocusable(false);

    menu.add(titulo);

    menu.addSeparator();

    // Actualizar posicin
    final JMenuItem gps = new JMenuItem(i18n.getString("map.menu.gps"), KeyEvent.VK_P);
    gps.setIcon(LogicConstants.getIcon("menucontextual_icon_actualizargps"));
    menu.add(gps);
    gps.addActionListener(this);
    gps.setEnabled(false);

    menu.addSeparator();

    // Mostrar ms cercanos
    final JMenuItem mmc = new JMenuItem(i18n.getString("map.menu.showNearest"), KeyEvent.VK_M);
    mmc.setIcon(LogicConstants.getIcon("menucontextual_icon_mascercano"));
    mmc.addActionListener(this);
    menu.add(mmc);
    // Centrar aqui
    final JMenuItem cent = new JMenuItem(i18n.getString("map.menu.centerHere"), KeyEvent.VK_C);
    cent.setIcon(LogicConstants.getIcon("menucontextual_icon_centrar"));
    cent.addActionListener(this);
    menu.add(cent);
    // Nueva Incidencia
    final JMenuItem newIncidence = new JMenuItem(i18n.getString("map.menu.newIncidence"), KeyEvent.VK_I);
    newIncidence.setIcon(LogicConstants.getIcon("menucontextual_icon_newIncidence"));
    newIncidence.addActionListener(this);
    menu.add(newIncidence);
    // Calcular ruta desde aqui
    final JMenuItem from = new JMenuItem(i18n.getString("map.menu.route.from"), KeyEvent.VK_D);
    from.setIcon(LogicConstants.getIcon("menucontextual_icon_origenruta"));
    from.addActionListener(this);
    menu.add(from);
    // Calcular ruta hasta aqui
    final JMenuItem to = new JMenuItem(i18n.getString("map.menu.route.to"), KeyEvent.VK_H);
    to.setIcon(LogicConstants.getIcon("menucontextual_icon_destinoruta"));
    to.addActionListener(this);
    menu.add(to);

    menu.addSeparator();

    // Ver ficha [recurso / incidencia]
    final JMenuItem summary = new JMenuItem(i18n.getString("map.menu.summary"), KeyEvent.VK_F);
    summary.setIcon(LogicConstants.getIcon("menucontextual_icon_ficha"));
    summary.addActionListener(this);
    menu.add(summary);
    summary.setEnabled(false);

    menu.addPopupMenuListener(new PopupMenuListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            eventOriginal = FleetControlMapViewer.this.mapView.lastMEvent;
            gps.setEnabled(false);
            summary.setEnabled(false);
            titulo.setText(i18n.getString("map.menu.titulo.puntoGenerico"));
            menuObjective = null;
            Point p = new Point(mapView.lastMEvent.getX(), mapView.lastMEvent.getY());
            for (Layer l : mapView.getAllLayers()) { // por cada capa...
                if (l instanceof MarkerLayer) { // ...de marcadores
                    for (Marker marker : ((MarkerLayer) l).data) { // miramos
                        // los
                        // marcadores
                        if ((marker instanceof CustomMarker) && marker.containsPoint(p)) { // y si
                            // estamos
                            // pinchando
                            // en uno
                            CustomMarker m = (CustomMarker) marker;
                            log.trace("Hemos pinchado en " + marker);

                            switch (m.getType()) {
                            case RESOURCE:
                                Recurso r = (Recurso) m.getObject();
                                log.trace("Es un recurso: " + r);
                                if (r != null) {
                                    menuObjective = r;
                                    if (r.getPatrullas() != null) {
                                        titulo.setText(
                                                i18n.getString(Locale.ROOT, "map.menu.titulo.recursoPatrulla",
                                                        r.getIdentificador(), r.getPatrullas()));
                                    } else {
                                        titulo.setText(r.getIdentificador());
                                    }
                                    gps.setEnabled(true);
                                    summary.setEnabled(true);
                                }
                                break;
                            case INCIDENCE:
                                Incidencia i = (Incidencia) m.getObject();
                                log.trace("Es una incidencia: " + i);
                                if (i != null) {
                                    menuObjective = i;
                                    titulo.setText(i.getTitulo());
                                    gps.setEnabled(false);
                                    summary.setEnabled(true);
                                }
                                break;
                            case UNKNOWN:
                                log.trace("Hemos pinchado en un marcador desconocido");
                                break;
                            }

                        }
                    }
                }
            }
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
        }
    });

    return menu;
}

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);//from   w  w  w  . ja  v  a  2 s  .  c o m

    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:base.BasePlayer.Main.java

static void addAnnotationFile(String genomeName, File annotationFile) {
    boolean first = false;

    if (genomehash.get(genomeName) == null) {
        genomehash.put(genomeName, new ArrayList<File>());
    }//  w  w w  . ja v a  2s .  c  o m
    if (genome.getItemCount() == 0) {
        first = true;
    }

    genomehash.get(genomeName).add(annotationFile);
    JMenuItem additem = new JMenuItem(
            annotationFile.getName().substring(0, annotationFile.getName().indexOf(".bed.gz")));
    additem.setName(annotationFile.getName().substring(0, annotationFile.getName().indexOf(".bed.gz")));
    additem.addMouseListener(Main.thisMainListener);

    for (int i = 1; i < genome.getItemCount(); i++) {

        if (genome.getItem(i).getName().equals(genomeName)) {
            JMenu addMenu = (JMenu) genome.getItem(i);
            addMenu.setFont(menuFont);
            if (first) {
                JMenuItem addAnnotation = new JMenuItem("Add new annotation file...");
                addAnnotation.setFont(menuFont);
                addAnnotation.addMouseListener(Main.thisMainListener);
                addAnnotation.setName("add_annotation");
                addMenu.add(addAnnotation);
                JLabel addLabel = new JLabel("  Select annotation: ");
                addLabel.setFont(menuFont);
                labels.add(addLabel);
                addMenu.add(addLabel);
                addMenu.add(new JSeparator());
            }
            additem.setFont(menuFont);
            addMenu.add(additem);
            addMenu.revalidate();
            genome.revalidate();
            break;
        }
    }
    Main.defaultAnnotation = annotationFile.getName();
    setChromDrop(genomeName);
}

From source file:org.gofleet.module.routing.RoutingMap.java

@Override
protected JPopupMenu getContextMenu() {
    JPopupMenu menu = new JPopupMenu();

    menu.setBackground(Color.decode("#E8EDF6"));

    String mapMenuTituloPlanning = i18n.getString("map.menu.titulo.planning");
    String mapMenuNewPlanning = i18n.getString("map.menu.new.planning");
    // Ttulo//from  w  ww. j a va 2  s .  c  o m
    final JMenuItem titulo = new JMenuItem(mapMenuTituloPlanning);
    titulo.setFont(LogicConstants.deriveBoldFont(10.0f));
    titulo.setBackground(Color.decode("#A4A4A4"));
    titulo.setFocusable(false);

    menu.add(titulo);

    // New Planning
    final JMenuItem to = new JMenuItem(mapMenuNewPlanning, KeyEvent.VK_F6);
    to.setIcon(LogicConstants.getIcon("menucontextual_icon_destinoruta"));
    to.addActionListener(this);
    menu.add(to);

    menu.addSeparator();

    return menu;
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java

/**
 * Sets the defaults of the specified menu item.
 * //from www . j av a  2  s .co  m
 * @param item The menu item.
 */
private void initMenuItem(JMenuItem item) {
    item.setBorder(null);
    item.setFont((Font) TreeViewerAgent.getRegistry().lookup("/resources/fonts/Labels"));
}