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

/**
 * Creates a suitable menu item.//from  ww w. ja  v a  2 s .c  o  m
 * 
 * @param action
 * @return
 */
public static JMenuItem createMenuItem(Action action) {
    final JMenuItem mi;
    final Boolean selected = (Boolean) action.getValue(Action.SELECTED_KEY);
    if (selected != null) {
        mi = new JCheckBoxMenuItem(action);
    } else {
        mi = new JMenuItem(action);
    }
    mi.setHorizontalTextPosition(JButton.TRAILING);
    mi.setVerticalTextPosition(JButton.CENTER);
    return mi;
}

From source file:Main.java

public Main() {
    popup = new JPopupMenu();
    ActionListener menuListener = new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            System.out.println("Popup menu item [" + event.getActionCommand() + "] was pressed.");
        }//w  w w . j  a v  a2 s  .co m
    };
    JMenuItem item;
    popup.add(item = new JMenuItem("Left"));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.add(item = new JMenuItem("Center", new ImageIcon("center.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.add(item = new JMenuItem("Right", new ImageIcon("right.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.add(item = new JMenuItem("Full", new ImageIcon("full.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.addSeparator();
    popup.add(item = new JMenuItem("Settings . . ."));
    item.addActionListener(menuListener);

    popup.setLabel("Justification");
    popup.setBorder(new BevelBorder(BevelBorder.RAISED));
    popup.addPopupMenuListener(new PopupPrintListener());

    addMouseListener(new MousePopupListener());
}

From source file:Main.java

public Main() {
    popup = new JPopupMenu();
    ActionListener menuListener = new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            System.out.println("Popup menu item [" + event.getActionCommand() + "] was pressed.");
        }//from  w ww.jav a 2s . c  o m
    };
    JMenuItem item;
    popup.add(item = new JMenuItem(new ImageIcon("left.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.add(item = new JMenuItem("Center", new ImageIcon("center.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.add(item = new JMenuItem("Right", new ImageIcon("right.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.add(item = new JMenuItem("Full", new ImageIcon("full.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.addSeparator();
    popup.add(item = new JMenuItem("Settings . . ."));
    item.addActionListener(menuListener);

    popup.setLabel("Justification");
    popup.setBorder(new BevelBorder(BevelBorder.RAISED));
    popup.addPopupMenuListener(new PopupPrintListener());

    addMouseListener(new MousePopupListener());
}

From source file:MainClass.java

public MainClass() {
    popup = new JPopupMenu();
    ActionListener menuListener = new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            System.out.println("Popup menu item [" + event.getActionCommand() + "] was pressed.");
        }/*  www.ja v a 2 s. co m*/
    };
    JMenuItem item;
    popup.add(item = new JMenuItem("Left", new ImageIcon("left.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.add(item = new JMenuItem("Center", new ImageIcon("center.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.add(item = new JMenuItem("Right", new ImageIcon("right.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.add(item = new JMenuItem("Full", new ImageIcon("full.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.addSeparator();
    popup.add(item = new JMenuItem("Settings . . ."));
    item.addActionListener(menuListener);

    popup.setLabel("Justification");
    popup.setBorder(new BevelBorder(BevelBorder.RAISED));
    popup.addPopupMenuListener(new PopupPrintListener());

    addMouseListener(new MousePopupListener());
}

From source file:Main.java

public Main() {
    popup = new JPopupMenu();
    ActionListener menuListener = new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            System.out.println("Popup menu item [" + event.getActionCommand() + "] was pressed.");
        }//ww w. ja  va 2s . c  o  m
    };
    JMenuItem item;
    popup.add(item = new JMenuItem("Left", new ImageIcon("left.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.add(item = new JMenuItem("Center", new ImageIcon("center.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.add(item = new JMenuItem("Right", new ImageIcon("right.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.add(item = new JMenuItem("Full", new ImageIcon("full.gif")));
    item.setHorizontalTextPosition(JMenuItem.RIGHT);
    item.addActionListener(menuListener);
    popup.addSeparator();
    popup.add(item = new JMenuItem("Settings . . ."));
    item.addActionListener(menuListener);

    popup.setLabel("Justification");
    popup.setBorder(new BevelBorder(BevelBorder.RAISED));
    popup.addPopupMenuListener(new PopupPrintListener());

    addMouseListener(new MousePopupListener());
}

From source file:gdt.jgui.entity.contact.JContactFacetOpenItem.java

@Override
public JPopupMenu getPopupMenu(final String digestLocator$) {
    JPopupMenu popup = new JPopupMenu();
    JMenuItem editItem = new JMenuItem("Edit");
    popup.add(editItem);/*from   w  w w . j a v  a 2 s. c om*/
    editItem.setHorizontalTextPosition(JMenuItem.RIGHT);
    editItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //System.out.println("JContactFacetOpenItem:edit:digest locator="+digestLocator$);
            try {
                Properties locator = Locator.toProperties(digestLocator$);
                String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
                String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
                Entigrator entigrator = console.getEntigrator(entihome$);
                JContactEditor ce = new JContactEditor();
                String ceLocator$ = ce.getLocator();
                ceLocator$ = Locator.append(ceLocator$, Entigrator.ENTIHOME, entihome$);
                ceLocator$ = Locator.append(ceLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                JConsoleHandler.execute(console, ceLocator$);

            } catch (Exception ee) {
                Logger.getLogger(JContactFacetOpenItem.class.getName()).info(ee.toString());
            }
        }
    });
    return popup;

}

From source file:gdt.jgui.entity.email.JEmailFacetOpenItem.java

@Override
public JPopupMenu getPopupMenu(final String digestLocator$) {

    JPopupMenu popup = new JPopupMenu();
    JMenuItem editItem = new JMenuItem("Edit");
    popup.add(editItem);/*from w  w w.  j ava  2s  . c om*/
    editItem.setHorizontalTextPosition(JMenuItem.RIGHT);
    editItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //System.out.println("JEmailFacetOpenItem:edit:digest locator="+digestLocator$);
            try {
                Properties locator = Locator.toProperties(digestLocator$);
                String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
                String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
                Entigrator entigrator = console.getEntigrator(entihome$);
                Sack entity = entigrator.getEntityAtKey(entityKey$);
                String email$ = entity.getProperty("email");
                JTextEditor te = new JTextEditor();
                String teLocator$ = te.getLocator();
                teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, email$);
                String foiLocator$ = getLocator();
                foiLocator$ = Locator.append(foiLocator$, BaseHandler.HANDLER_METHOD, METHOD_RESPONSE);
                foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_ACTION, ACTION_DIGEST_CALL);
                foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                        Locator.compressText(digestLocator$));
                teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                        Locator.compressText(foiLocator$));
                //System.out.println("JEmailFacetOpenItem:edit:text editor="+teLocator$);
                JConsoleHandler.execute(console, teLocator$);
            } catch (Exception ee) {
                Logger.getLogger(JEmailFacetOpenItem.class.getName()).info(ee.toString());
            }
        }
    });
    return popup;

}

From source file:gdt.jgui.entity.phone.JPhoneFacetOpenItem.java

@Override
public JPopupMenu getPopupMenu(final String digestLocator$) {
    JPopupMenu popup = new JPopupMenu();
    JMenuItem editItem = new JMenuItem("Edit");
    popup.add(editItem);/*from  ww w  .  j a  va  2s. co  m*/
    editItem.setHorizontalTextPosition(JMenuItem.RIGHT);
    editItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("JPhoneFacetOpenItem:edit:digest locator=" + digestLocator$);
            try {
                Properties locator = Locator.toProperties(digestLocator$);
                String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
                String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
                Entigrator entigrator = console.getEntigrator(entihome$);
                Sack entity = entigrator.getEntityAtKey(entityKey$);
                String phone$ = entity.getProperty("phone");
                JTextEditor te = new JTextEditor();
                String teLocator$ = te.getLocator();
                teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, phone$);
                String foiLocator$ = getLocator();
                foiLocator$ = Locator.append(foiLocator$, BaseHandler.HANDLER_METHOD, METHOD_RESPONSE);
                foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_ACTION, ACTION_DIGEST_CALL);
                foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                        Locator.compressText(digestLocator$));
                teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                        Locator.compressText(foiLocator$));
                System.out.println("JPhoneFacetOpenItem:edit:text editor=" + teLocator$);
                JConsoleHandler.execute(console, teLocator$);
            } catch (Exception ee) {
                Logger.getLogger(JPhoneFacetOpenItem.class.getName()).info(ee.toString());
            }
        }
    });
    return popup;
}

From source file:gdt.jgui.entity.bookmark.JBookmarksFacetOpenItem.java

/**
 * Get the popup menu for the child node of the facet node 
 * in the digest view.//  w  w w  .  j  a v a2 s .  co  m
 * @return the popup menu.   
 */
@Override
public JPopupMenu getPopupMenu(final String digestLocator$) {
    JPopupMenu popup = new JPopupMenu();
    JMenuItem openItem = new JMenuItem("Open");
    popup.add(openItem);
    openItem.setHorizontalTextPosition(JMenuItem.RIGHT);
    openItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                //                 System.out.println("JBookmarkFacetOpenItem:open:digest locator="+digestLocator$); 
                Properties locator = Locator.toProperties(digestLocator$);
                String encodedSelection$ = locator.getProperty(JEntityDigestDisplay.SELECTION);
                byte[] ba = Base64.decodeBase64(encodedSelection$);
                String selection$ = new String(ba, "UTF-8");
                //                  System.out.println("JBookmarkFacetOpenItem:open:selection="+selection$);
                locator = Locator.toProperties(selection$);
                String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
                String type$ = locator.getProperty(Locator.LOCATOR_TYPE);
                if (JFolderPanel.LOCATOR_TYPE_FILE.equals(type$)) {
                    String filePath$ = locator.getProperty(JFolderPanel.FILE_PATH);
                    File file = new File(filePath$);
                    Desktop.getDesktop().open(file);
                    return;
                }
                if (JEntityDigestDisplay.LOCATOR_FACET_COMPONENT.equals(type$)) {
                    String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
                    JBookmarksEditor be = new JBookmarksEditor();
                    String beLocator$ = be.getLocator();
                    beLocator$ = Locator.append(beLocator$, Entigrator.ENTIHOME, entihome$);
                    beLocator$ = Locator.append(beLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    JConsoleHandler.execute(console, beLocator$);
                    return;
                }
                String bookmarkKey$ = locator.getProperty(JBookmarksEditor.BOOKMARK_KEY);
                Entigrator entigrator = console.getEntigrator(entihome$);
                String componentKey$ = locator.getProperty(JEntityDigestDisplay.COMPONENT_KEY);
                Sack entity = entigrator.getEntityAtKey(componentKey$);
                Core bookmark = entity.getElementItem("jbookmark", bookmarkKey$);
                //                  System.out.println("JBookmarkFacetOpenItem:open:selection="+selection$);
                JConsoleHandler.execute(console, bookmark.value);
            } catch (Exception ee) {
                Logger.getLogger(JBookmarksFacetOpenItem.class.getName()).info(ee.toString());
            }
        }
    });
    return popup;
}

From source file:gdt.jgui.entity.webset.JWebsetFacetOpenItem.java

/**
 * Get the popup menu for the child node of the facet node 
 * in the digest view./*from w  w  w .j a v  a 2 s  .c om*/
 * @return the popup menu.   
 */
@Override
public JPopupMenu getPopupMenu(final String digestLocator$) {
    JPopupMenu popup = new JPopupMenu();
    JMenuItem openItem = new JMenuItem("Open");
    popup.add(openItem);
    openItem.setHorizontalTextPosition(JMenuItem.RIGHT);
    openItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                //     System.out.println("JWebsetFacetOpenItem:open:digest locator="+digestLocator$); 
                Properties locator = Locator.toProperties(digestLocator$);
                String encodedSelection$ = locator.getProperty(JEntityDigestDisplay.SELECTION);
                byte[] ba = Base64.decodeBase64(encodedSelection$);
                String selection$ = new String(ba, "UTF-8");
                //      System.out.println("JWebsetFacetOpenItem:open:selection="+selection$);
                locator = Locator.toProperties(selection$);
                String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
                String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
                String type$ = locator.getProperty(Locator.LOCATOR_TYPE);
                if (LOCATOR_TYPE_WEB_ADDRESS.equals(type$)) {
                    try {
                        String url$ = locator.getProperty(JWeblinksPanel.WEB_LINK_URL);
                        //                        System.out.println("weblinkEditor:browseUrl:url="+url$);
                        Desktop.getDesktop().browse(new URI(url$));
                    } catch (Exception ee) {
                        Logger.getLogger(JFileOpenItem.class.getName()).info(ee.toString());
                    }
                    return;
                }
                if (JEntityDigestDisplay.LOCATOR_FACET_COMPONENT.equals(type$)) {
                    // String entityKey$=locator.getProperty(EntityHandler.ENTITY_KEY);
                    JWeblinkEditor we = new JWeblinkEditor();
                    String weLocator$ = we.getLocator();
                    weLocator$ = Locator.append(weLocator$, Entigrator.ENTIHOME, entihome$);
                    weLocator$ = Locator.append(weLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    //JConsoleHandler.execute(console,beLocator$);
                    return;
                }
                String weblinkKey$ = locator.getProperty(JWeblinksPanel.WEB_LINK_KEY);
                JWeblinkEditor we = new JWeblinkEditor();
                String weLocator$ = we.getLocator();
                weLocator$ = Locator.append(weLocator$, Entigrator.ENTIHOME, entihome$);
                weLocator$ = Locator.append(weLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                weLocator$ = Locator.append(weLocator$, JWeblinksPanel.WEB_LINK_KEY, weblinkKey$);
                /*
                Entigrator entigrator=console.getEntigrator(entihome$);
                String componentKey$=locator.getProperty(JEntityDigestDisplay.COMPONENT_KEY);
                Sack entity=entigrator.getEntityAtKey(componentKey$);
                Core weblink=entity.getElementItem("web", weblinkKey$);
                */
                //                  System.out.println("JBookmarkFacetOpenItem:open:selection="+selection$);
                JConsoleHandler.execute(console, weLocator$);
            } catch (Exception ee) {
                Logger.getLogger(JWebsetFacetOpenItem.class.getName()).info(ee.toString());
            }
        }
    });
    return popup;
}