List of usage examples for javax.swing JMenuItem setHorizontalTextPosition
@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)
From source file:gdt.jgui.entity.fields.JFieldsFacetOpenItem.java
/** * Get the popup menu for the child node of the facet node * in the digest view.//from w ww. j av a 2 s . c o m * @return the popup menu. */ @Override public JPopupMenu getPopupMenu(final String digestLocator$) { System.out.println("JFieldsFacetOpenItem:getPopupMenu:digest locator=" + Locator.remove(digestLocator$, Locator.LOCATOR_ICON)); JPopupMenu popup = new JPopupMenu(); JMenuItem editItem = new JMenuItem("Edit"); popup.add(editItem); editItem.setHorizontalTextPosition(JMenuItem.RIGHT); editItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Properties locator = Locator.toProperties(digestLocator$); String encodedSelection$ = locator.getProperty(JEntityDigestDisplay.SELECTION); byte[] ba = Base64.decodeBase64(encodedSelection$); String selection$ = new String(ba, "UTF-8"); locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); String nodeType$ = locator.getProperty(JEntityDigestDisplay.NODE_TYPE); System.out.println("JFieldsFacetOpenItem:getPopupMenu:node type:" + nodeType$); Entigrator entigrator = console.getEntigrator(entihome$); // Sack entity=entigrator.getEntityAtKey(entityKey$); if (NODE_TYPE_FIELD_NAME.equals(nodeType$)) { String fieldName$ = locator.getProperty(Locator.LOCATOR_TITLE); JTextEditor te = new JTextEditor(); String teLocator$ = te.getLocator(); teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, fieldName$); if (entihome$ != null) teLocator$ = Locator.append(teLocator$, Entigrator.ENTIHOME, entihome$); if (entityKey$ != null) teLocator$ = Locator.append(teLocator$, EntityHandler.ENTITY_KEY, entityKey$); 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$, FIELD_NAME, fieldName$); foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, Locator.compressText(digestLocator$)); if (entihome$ != null) foiLocator$ = Locator.append(foiLocator$, Entigrator.ENTIHOME, entihome$); if (entityKey$ != null) foiLocator$ = Locator.append(foiLocator$, EntityHandler.ENTITY_KEY, entityKey$); System.out.println("JFieldsFacetOpenItem:getPopupMenu:name:locator=" + foiLocator$); teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, Locator.compressText(foiLocator$)); JConsoleHandler.execute(console, teLocator$); System.out.println("JFieldsFacetOpenItem:getPopupMenu:teLocator=" + teLocator$); return; } if (NODE_TYPE_FIELD_VALUE.equals(nodeType$)) { String fieldName$ = locator.getProperty(Locator.LOCATOR_TITLE); JTextEditor te = new JTextEditor(); String teLocator$ = te.getLocator(); teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, fieldName$); if (entihome$ != null) teLocator$ = Locator.append(teLocator$, Entigrator.ENTIHOME, entihome$); if (entityKey$ != null) teLocator$ = Locator.append(teLocator$, EntityHandler.ENTITY_KEY, entityKey$); 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$, FIELD_NAME, fieldName$); foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, Locator.compressText(digestLocator$)); if (entihome$ != null) foiLocator$ = Locator.append(foiLocator$, Entigrator.ENTIHOME, entihome$); if (entityKey$ != null) foiLocator$ = Locator.append(foiLocator$, EntityHandler.ENTITY_KEY, entityKey$); System.out.println("JFieldsFacetOpenItem:getPopupMenu:value:locator=" + foiLocator$); teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, Locator.compressText(foiLocator$)); JConsoleHandler.execute(console, teLocator$); return; } if (JEntityDigestDisplay.NODE_TYPE_FACET_OWNER.equals(nodeType$)) { JEntityDigestDisplay edd = new JEntityDigestDisplay(); String eddLocator$ = edd.getLocator(); eddLocator$ = Locator.append(eddLocator$, Entigrator.ENTIHOME, entihome$); eddLocator$ = Locator.append(eddLocator$, EntityHandler.ENTITY_KEY, entityKey$); eddLocator$ = Locator.append(eddLocator$, JEntityDigestDisplay.SELECTION, encodedSelection$); String requesterResponseLocator$ = Locator.compressText(eddLocator$); JFieldsEditor fieldsEditor = new JFieldsEditor(); String feLocator$ = fieldsEditor.getLocator(); feLocator$ = Locator.append(feLocator$, Entigrator.ENTIHOME, entihome$); feLocator$ = Locator.append(feLocator$, EntityHandler.ENTITY_KEY, entityKey$); feLocator$ = Locator.append(feLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, requesterResponseLocator$); feLocator$ = Locator.append(feLocator$, BaseHandler.HANDLER_METHOD, "instantiate"); JConsoleHandler.execute(console, feLocator$); } } catch (Exception ee) { Logger.getLogger(JFieldsFacetOpenItem.class.getName()).info(ee.toString()); } } }); return popup; }
From source file:gdt.jgui.entity.folder.JFolderFacetOpenItem.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(); try { Properties locator = Locator.toProperties(digestLocator$); final String encodedSelection$ = locator.getProperty(JEntityDigestDisplay.SELECTION); byte[] ba = Base64.decodeBase64(encodedSelection$); final String selection$ = new String(ba, "UTF-8"); // System.out.println("JFolderFacetOpenItem:getPopupMenu:selection:="+selection$); locator = Locator.toProperties(selection$); String nodeType$ = locator.getProperty(JEntityDigestDisplay.NODE_TYPE); if (JEntityDigestDisplay.NODE_TYPE_FACET_OWNER.equals(nodeType$)) { JMenuItem openItem = new JMenuItem("Open"); popup.add(openItem); openItem.setHorizontalTextPosition(JMenuItem.RIGHT); openItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); File file = new File(entihome$ + "/" + entityKey$); Desktop.getDesktop().open(file); } catch (Exception ee) { Logger.getLogger(JFieldsFacetOpenItem.class.getName()).info(ee.toString()); } } }); JMenuItem editItem = new JMenuItem("Edit"); popup.add(editItem); editItem.setHorizontalTextPosition(JMenuItem.RIGHT); editItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); JFolderPanel fp = new JFolderPanel(); String fpLocator$ = fp.getLocator(); fpLocator$ = Locator.append(fpLocator$, Entigrator.ENTIHOME, entihome$); fpLocator$ = Locator.append(fpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, fpLocator$); } catch (Exception ee) { Logger.getLogger(JFieldsFacetOpenItem.class.getName()).info(ee.toString()); } } }); } if (NODE_TYPE_FILE_NODE.equals(nodeType$)) { JMenuItem openItem = new JMenuItem("Open"); popup.add(openItem); openItem.setHorizontalTextPosition(JMenuItem.RIGHT); openItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Properties locator = Locator.toProperties(selection$); String filePath$ = locator.getProperty(JFolderPanel.FILE_PATH); File file = new File(filePath$); Desktop.getDesktop().open(file); } catch (Exception ee) { Logger.getLogger(JFieldsFacetOpenItem.class.getName()).info(ee.toString()); } } }); String filePath$ = locator.getProperty(JFolderPanel.FILE_PATH); final File file = new File(filePath$); if (isTextFile(file)) { JMenuItem editItem = new JMenuItem("Edit"); popup.add(editItem); editItem.setHorizontalTextPosition(JMenuItem.RIGHT); editItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { InputStream is = new FileInputStream(file); ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] b = new byte[1024]; int bytesRead = 0; while ((bytesRead = is.read(b)) != -1) { bos.write(b, 0, bytesRead); } byte[] ba = bos.toByteArray(); is.close(); String text$ = new String(ba, "UTF-8"); JTextEditor te = new JTextEditor(); String teLocator$ = te.getLocator(); teLocator$ = Locator.append(teLocator$, Entigrator.ENTIHOME, entihome$); teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, text$); locator$ = Locator.append(locator$, JRequester.REQUESTER_ACTION, JFolderPanel.ACTION_EDIT_FILE); locator$ = Locator.append(locator$, JFolderPanel.FILE_PATH, file.getPath()); locator$ = Locator.append(locator$, BaseHandler.HANDLER_METHOD, "response"); locator$ = Locator.append(locator$, JEntityDigestDisplay.SELECTION, encodedSelection$); String requesterResponceLocator$ = Locator.compressText(locator$); teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, requesterResponceLocator$); JConsoleHandler.execute(console, teLocator$); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); } } return popup; } catch (Exception e) { Logger.getLogger(getClass().getName()).severe(e.toString()); return null; } }
From source file:gdt.jgui.entity.JEntityStructurePanel.java
/** * The default constructor./*from w ww .ja v a 2 s . c o m*/ */ public JEntityStructurePanel() { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); scrollPane = new JScrollPane(); add(scrollPane); popup = new JPopupMenu(); popup.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { popup.removeAll(); JMenuItem facetsItem = new JMenuItem("Facets"); popup.add(facetsItem); facetsItem.setHorizontalTextPosition(JMenuItem.RIGHT); facetsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // System.out.println("EntityStructurePanel:renderer:component locator$="+nodeLocator$); JEntityFacetPanel efp = new JEntityFacetPanel(); String efpLocator$ = efp.getLocator(); Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$); efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, efpLocator$); } }); JMenuItem copyItem = new JMenuItem("Copy"); popup.add(copyItem); copyItem.setHorizontalTextPosition(JMenuItem.RIGHT); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { console.clipboard.clear(); String locator$ = (String) node.getUserObject(); if (locator$ != null) console.clipboard.putString(locator$); } }); if (!isFirst) { popup.addSeparator(); JMenuItem excludeItem = new JMenuItem("Exclude"); popup.add(excludeItem); excludeItem.setHorizontalTextPosition(JMenuItem.RIGHT); excludeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Exclude ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); Sack component = entigrator.getEntityAtKey(entityKey$); String[] sa = entigrator.ent_listContainers(component); if (sa != null) { Sack container; for (String aSa : sa) { container = entigrator.getEntityAtKey(aSa); if (container != null) entigrator.col_breakRelation(container, component); } } JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$); } catch (Exception ee) { Logger.getLogger(JEntityStructurePanel.class.getName()).info(ee.toString()); } } } }); JMenuItem deleteItem = new JMenuItem("Delete"); popup.add(deleteItem); deleteItem.setHorizontalTextPosition(JMenuItem.RIGHT); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); Sack component = entigrator.getEntityAtKey(entityKey$); entigrator.deleteEntity(component); JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$); } catch (Exception ee) { Logger.getLogger(JEntityStructurePanel.class.getName()).info(ee.toString()); } } } }); } if (hasToInclude()) { popup.addSeparator(); JMenuItem includeItem = new JMenuItem("Include"); popup.add(includeItem); includeItem.setHorizontalTextPosition(JMenuItem.RIGHT); includeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { include(); JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$); } }); } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { // TODO Auto-generated method stub } }); }
From source file:gdt.jgui.entity.JEntityDigestDisplay.java
private JPopupMenu getFacetComponentMenu() { JPopupMenu popup = new JPopupMenu(); JMenuItem openItem = new JMenuItem("Open"); popup.add(openItem);//from w ww . ja v a2 s . c om openItem.setHorizontalTextPosition(JMenuItem.RIGHT); openItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //System.out.println("JEmailFacetOpenItem:edit:digest locator="+digestLocator$); try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); JEntityFacetPanel efp = new JEntityFacetPanel(); String efpLocator$ = efp.getLocator(); efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$); efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entityKey$); //System.out.println("JEmailFacetOpenItem:edit:text editor="+teLocator$); JConsoleHandler.execute(console, efpLocator$); } catch (Exception ee) { Logger.getLogger(JEntityDigestDisplay.class.getName()).info(ee.toString()); } } }); return popup; }
From source file:gdt.jgui.entity.JEntityDigestDisplay.java
private JPopupMenu getCollapsePopupMenu() { //System.out.println("JEntityDigestDisplay:getCollapsePopupMenu:selection="+Locator.remove(selection$, Locator.LOCATOR_ICON)); JPopupMenu popup = new JPopupMenu(); JMenuItem collapseItem = new JMenuItem("Collapse"); popup.add(collapseItem);/* www.j a v a 2 s . c om*/ collapseItem.setHorizontalTextPosition(JMenuItem.RIGHT); collapseItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); int cnt = node.getChildCount(); Stack<DefaultMutableTreeNode> s = new Stack<DefaultMutableTreeNode>(); if (cnt > 0) { DefaultMutableTreeNode child; for (int i = 0; i < cnt; i++) { child = (DefaultMutableTreeNode) node.getChildAt(i); s.push(child); } } while (!s.isEmpty()) tree.collapsePath(new TreePath(s.pop().getPath())); } catch (Exception ee) { } } }); return popup; }
From source file:gdt.jgui.entity.webset.JWeblinkEditor.java
private void showLoginMenu(MouseEvent e) { try {/*from www .ja v a 2 s . co m*/ JPopupMenu logonMenu = new JPopupMenu(); JMenuItem copyItem = new JMenuItem("Copy"); logonMenu.add(copyItem); copyItem.setHorizontalTextPosition(JMenuItem.RIGHT); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { StringSelection stringSelection = new StringSelection(loginField.getText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, JWeblinkEditor.this); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); logonMenu.show(e.getComponent(), e.getX(), e.getY()); } catch (Exception ee) { Logger.getLogger(getClass().getName()).severe(ee.toString()); } }
From source file:gdt.jgui.entity.webset.JWeblinkEditor.java
private void showPasswordMenu(MouseEvent e) { try {/*from www . j ava 2 s .c o m*/ JPopupMenu passwordMenu = new JPopupMenu(); JMenuItem copyItem = new JMenuItem("Copy"); passwordMenu.add(copyItem); copyItem.setHorizontalTextPosition(JMenuItem.RIGHT); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { StringSelection stringSelection = new StringSelection(passwordField.getText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, JWeblinkEditor.this); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); JMenuItem encodeItem = new JMenuItem("Encrypt/decrypt"); passwordMenu.add(encodeItem); encodeItem.setHorizontalTextPosition(JMenuItem.RIGHT); encodeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { save(); JTextEncrypter te = new JTextEncrypter(); String teLocator$ = te.getLocator(); teLocator$ = Locator.append(teLocator$, Entigrator.ENTIHOME, entihome$); teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, passwordField.getText()); teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT_TITLE, nameField.getText()); String weLocator$ = JWeblinkEditor.this.getLocator(); weLocator$ = Locator.append(weLocator$, BaseHandler.HANDLER_METHOD, "response"); weLocator$ = Locator.append(weLocator$, JRequester.REQUESTER_ACTION, ACTION_ENCODE_PASSWORD); teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, Locator.compressText(weLocator$)); JConsoleHandler.execute(console, teLocator$); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); passwordMenu.show(e.getComponent(), e.getX(), e.getY()); } catch (Exception ee) { Logger.getLogger(getClass().getName()).severe(ee.toString()); } }
From source file:gdt.jgui.entity.webset.JWeblinkEditor.java
private void showIconMenu(MouseEvent e) { try {/*from ww w. j a v a 2 s. c o m*/ iconMenu = new JPopupMenu(); JMenuItem loadItem = new JMenuItem("Load"); iconMenu.add(loadItem); loadItem.setHorizontalTextPosition(JMenuItem.RIGHT); loadItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { String favicon$ = "http://www.google.com/s2/favicons?domain=" + addressField.getText(); URL url = new URL(favicon$); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoInput(true); connection.connect(); InputStream input = connection.getInputStream(); ImageIcon icon = new ImageIcon(ImageIO.read(input)); int type = BufferedImage.TYPE_INT_RGB; BufferedImage out = new BufferedImage(24, 24, type); Color background = JWeblinkEditor.this.getBackground(); Graphics2D g2 = out.createGraphics(); g2.setBackground(background); g2.clearRect(0, 0, 24, 24); Image image = icon.getImage(); g2.drawImage(image, 4, 4, null); g2.dispose(); icon = new ImageIcon(out); iconIcon.setIcon(icon); input.close(); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); JMenuItem setItem = new JMenuItem("Set"); iconMenu.add(setItem); setItem.setHorizontalTextPosition(JMenuItem.RIGHT); setItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("WeblinkEditor:set icon"); JIconSelector is = new JIconSelector(); String isLocator$ = is.getLocator(); if (entihome$ != null) isLocator$ = Locator.append(isLocator$, Entigrator.ENTIHOME, entihome$); if (entityKey$ != null) isLocator$ = Locator.append(isLocator$, EntityHandler.ENTITY_KEY, entityKey$); String responseLocator$ = getLocator(); responseLocator$ = Locator.append(responseLocator$, JRequester.REQUESTER_ACTION, ACTION_SET_ICON); responseLocator$ = Locator.append(responseLocator$, BaseHandler.HANDLER_METHOD, "response"); isLocator$ = Locator.append(isLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, Locator.compressText(responseLocator$)); JConsoleHandler.execute(console, isLocator$); } }); iconMenu.show(e.getComponent(), e.getX(), e.getY()); } catch (Exception ee) { Logger.getLogger(getClass().getName()).severe(ee.toString()); } }
From source file:org.esa.nest.dat.views.polarview.PolarView.java
private JMenuItem createMenuItem(String name) { final JMenuItem item = new JMenuItem(name); item.setHorizontalTextPosition(JMenuItem.RIGHT); item.addActionListener(this); return item;/*from w w w . j a va2s .c o m*/ }
From source file:org.esa.snap.graphbuilder.rcp.dialogs.support.GraphPanel.java
/** * Creates a menu containing the list of operators to the addMenu *//* w w w. j av a2 s . c o m*/ private void CreateAddOpMenu() { addMenu = new JMenu("Add"); // get operator list from graph executor final Set<String> gpfOperatorSet = graphEx.GetOperatorList(); final String[] gpfOperatorList = new String[gpfOperatorSet.size()]; gpfOperatorSet.toArray(gpfOperatorList); Arrays.sort(gpfOperatorList); // add operators for (String anAlias : gpfOperatorList) { if (!graphEx.isOperatorInternal(anAlias) && OperatorUIRegistry.showInGraphBuilder(anAlias)) { final String category = graphEx.getOperatorCategory(anAlias); JMenu menu = addMenu; if (!category.isEmpty()) { final String[] categoryPath = StringUtils.split(category, folderDelim, true); for (String folder : categoryPath) { menu = getMenuFolder(folder, menu); } } final JMenuItem item = new JMenuItem(anAlias, opIcon); item.setHorizontalTextPosition(JMenuItem.RIGHT); item.addActionListener(addListener); menu.add(item); } } }