Example usage for javax.swing JMenuItem setHorizontalTextPosition

List of usage examples for javax.swing JMenuItem setHorizontalTextPosition

Introduction

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

Prototype

@BeanProperty(visualUpdate = true, enumerationValues = { "SwingConstants.LEFT", "SwingConstants.CENTER",
        "SwingConstants.RIGHT", "SwingConstants.LEADING",
        "SwingConstants.TRAILING" }, description = "The horizontal position of the text relative to the icon.")
public void setHorizontalTextPosition(int textPosition) 

Source Link

Document

Sets the horizontal position of the text relative to the icon.

Usage

From source file:org.esa.snap.graphbuilder.rcp.dialogs.support.GraphPanel.java

private void checkPopup(MouseEvent e) {
    if (e.isPopupTrigger()) {

        final JPopupMenu popup = new JPopupMenu();
        popup.add(addMenu);//from  w  w  w .  j  a  va2 s.  c om

        if (selectedNode != null) {
            final JMenuItem item = new JMenuItem("Delete");
            popup.add(item);
            item.setHorizontalTextPosition(JMenuItem.RIGHT);
            item.addActionListener(this);

            final NodeSource[] sources = selectedNode.getNode().getSources();
            if (sources.length > 0) {
                final JMenu removeSourcedMenu = new JMenu("Remove Source");
                for (NodeSource ns : sources) {
                    final JMenuItem nsItem = new JMenuItem(ns.getSourceNodeId());
                    removeSourcedMenu.add(nsItem);
                    nsItem.setHorizontalTextPosition(JMenuItem.RIGHT);
                    nsItem.addActionListener(removeSourceListener);
                }
                popup.add(removeSourcedMenu);
            }
        }

        if (!graphEx.getGraphNodeList().isGraphComplete()) {
            final JMenuItem connectItem = new JMenuItem("Connect Graph", null);
            connectItem.setHorizontalTextPosition(JMenuItem.RIGHT);
            connectItem.addActionListener(connectListener);
            popup.add(connectItem);
        }

        popup.setLabel("Justification");
        popup.setBorder(new BevelBorder(BevelBorder.RAISED));
        popup.addPopupMenuListener(this);
        popup.show(this, e.getX(), e.getY());
        showRightClickHelp = false;
    }
}

From source file:org.openscience.jmol.app.Jmol.java

/**
 * This is the hook through which all menu items are
 * created.  It registers the result with the menuitem
 * hashtable so that it can be fetched with getMenuItem().
 * @param cmd//from  ww w  . j a  v a2 s .c  o  m
 * @return Menu item created
 * @see #getMenuItem
 */
protected JMenuItem createMenuItem(String cmd) {

    JMenuItem mi;
    if (cmd.endsWith("Check")) {
        mi = guimap.newJCheckBoxMenuItem(cmd, false);
    } else {
        mi = guimap.newJMenuItem(cmd);
    }

    ImageIcon f = JmolResourceHandler.getIconX(cmd + "Image");
    if (f != null) {
        mi.setHorizontalTextPosition(SwingConstants.RIGHT);
        mi.setIcon(f);
    }

    if (cmd.endsWith("Script")) {
        mi.setActionCommand(JmolResourceHandler.getStringX(cmd));
        mi.addActionListener(executeScriptAction);
    } else {
        mi.setActionCommand(cmd);
        Action a = getAction(cmd);
        if (a != null) {
            mi.addActionListener(a);
            a.addPropertyChangeListener(new ActionChangedListener(mi));
            mi.setEnabled(a.isEnabled());
        } else {
            mi.setEnabled(false);
        }
    }
    menuItems.put(cmd, mi);
    return mi;
}