Example usage for javax.swing JMenu setHorizontalTextPosition

List of usage examples for javax.swing JMenu setHorizontalTextPosition

Introduction

In this page you can find the example usage for javax.swing JMenu 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.openscience.jmol.app.Jmol.java

/**
 * Create a menu for the app.  By default this pulls the
 * definition of the menu from the associated resource file.
 * @param key//from ww  w . j a  v  a 2s.c  o m
 * @return Menu created
 */
protected JMenu createMenu(String key) {

    // Get list of items from resource file:
    String[] itemKeys = tokenize(JmolResourceHandler.getStringX(key));

    // Get label associated with this menu:
    JMenu menu = guimap.newJMenu(key);
    ImageIcon f = JmolResourceHandler.getIconX(key + "Image");
    if (f != null) {
        menu.setHorizontalTextPosition(SwingConstants.RIGHT);
        menu.setIcon(f);
    }

    // Loop over the items in this menu:
    for (int i = 0; i < itemKeys.length; i++) {

        String item = itemKeys[i];
        if (item.equals("-")) {
            menu.addSeparator();
            continue;
        }
        if (item.endsWith("Menu")) {
            JMenu pm;
            if ("recentFilesMenu".equals(item)) {
                /*recentFilesMenu = */pm = createMenu(item);
            } else {
                pm = createMenu(item);
            }
            menu.add(pm);
            continue;
        }
        JMenuItem mi = createMenuItem(item);
        menu.add(mi);
    }
    menu.addMenuListener(display.getMenuListener());
    return menu;
}