List of usage examples for javax.swing JMenu setText
@BeanProperty(preferred = true, visualUpdate = true, description = "The button's text.") public void setText(String text)
From source file:JFlap_2.EditingGraphViewer1.java
/** * @param args the command line arguments *//* w w w . j a v a 2 s . c o m*/ public static void main(String[] args) { EditingGraphViewer1 sgv = new EditingGraphViewer1(); // Layout<V, E>, VisualizationViewer<V,E> Layout<Integer, String> layout = new StaticLayout(sgv.g); layout.setSize(new Dimension(300, 300)); VisualizationViewer<Integer, String> vv = new VisualizationViewer<Integer, String>(layout); vv.setPreferredSize(new Dimension(350, 350)); // Show vertex and edge labels vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); EditingModalGraphMouse gm = new EditingModalGraphMouse(vv.getRenderContext(), sgv.vertexFactory, sgv.edgeFactory); vv.setGraphMouse(gm); JFrame frame = new JFrame("Editing Graph Viewer 1"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); JMenuBar menuBar = new JMenuBar(); JMenu modeMenu = gm.getModeMenu(); modeMenu.setText("Mouse Mode"); modeMenu.setIcon(null); modeMenu.setPreferredSize(new Dimension(80, 20)); menuBar.add(modeMenu); frame.setJMenuBar(menuBar); gm.setMode(ModalGraphMouse.Mode.EDITING); frame.pack(); frame.setVisible(true); }
From source file:de.javagl.jgltf.browser.MenuNodes.java
/** * Create a list of menu items (which may be JMenu instances) for the * given {@link MenuNode} instances. //from ww w . j a va2 s. c om * * @param menuNodes The {@link MenuNode}s * @return The menus */ private static List<JMenuItem> createMenuItems(List<? extends MenuNode> menuNodes) { List<JMenuItem> menuItems = new ArrayList<JMenuItem>(); for (MenuNode menuNode : menuNodes) { if (menuNode.children != null) { JMenu menu = new JMenu(); menu.setText(menuNode.label); List<JMenuItem> childMenuItems = createMenuItems(menuNode.children); for (JMenuItem childMenuItem : childMenuItems) { menu.add(childMenuItem); } menuItems.add(menu); } else { if (menuNode.command == null) { logger.warning("Empty menu node - skipping"); continue; } JMenuItem menuItem = new JMenuItem(); String label = "<html>" + menuNode.label + " <font size=-2>(" + menuNode.command + ")</font>" + "</html>"; menuItem.setText(label); menuItem.setActionCommand(menuNode.command); menuItems.add(menuItem); } } return menuItems; }
From source file:net.sf.jabref.gui.menus.RightClickMenu.java
/** * Remove all types from the menu./*from w ww .j a v a 2 s .c o m*/ * Then cycle through all available values, and add them. */ public static void populateSpecialFieldMenu(JMenu menu, SpecialField field, JabRefFrame frame) { menu.setText(field.getMenuString()); menu.setIcon(((IconTheme.FontBasedIcon) field.getRepresentingIcon()).createSmallIcon()); for (SpecialFieldValue val : field.getValues()) { menu.add(val.getMenuAction(frame)); } }
From source file:net.sf.jabref.gui.RightClickMenu.java
/** * Remove all types from the menu.// w w w . j a v a 2 s . co m * Then cycle through all available values, and add them. */ public static void populateSpecialFieldMenu(JMenu menu, SpecialField field, JabRefFrame frame) { //menu.removeAll(); menu.setText(field.getMenuString()); menu.setIcon(((IconTheme.FontBasedIcon) field.getRepresentingIcon()).createSmallIcon()); for (SpecialFieldValue val : field.getValues()) { menu.add(val.getMenuAction(frame)); } }
From source file:levelBuilder.DialogMaker.java
/** * Various routines necessary for displaying graph. *//*w w w.j ava2 s. c om*/ private static void displayGraph() { JFrame frame = new JFrame("Dialog Maker"); layout = new KKLayout<DialogNode, Double>(g); VisualizationViewer<DialogNode, Double> vv = new VisualizationViewer<DialogNode, Double>(layout); layout.setSize(new Dimension(windowWidth, windowHeight)); vv.setPreferredSize(new Dimension(windowWidth, windowHeight)); //Changes fields in node properties window when a node is selected pickedState = vv.getPickedVertexState(); pickedState.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { Object subject = e.getItem(); if (subject instanceof DialogNode) { selectedNode = (DialogNode) subject; textField.setText(selectedNode.getText()); npcBox.setSelected(selectedNode.getIsNPC()); String working = ""; for (int c = 0; c < selectedNode.getChildren().length; c++) { if (c == 0) working += selectedNode.getChildren()[c].getText(); else working += "," + selectedNode.getChildren()[c].getText(); } if (working.equals("null")) working = ""; childrenField.setText(working.replace("]", "").replace("[", "")); working = Arrays.toString(selectedNode.getProbSets().get(strategy)); if (working.equals("null")) working = ""; probSetField.setText(working.replace("]", "").replace("[", "").replace(" ", "")); } } }); //Colors vertices according to 'initial', 'end', or 'middle' status. vv.getRenderContext().setVertexFillPaintTransformer(new Transformer<DialogNode, Paint>() { @Override public Paint transform(DialogNode n) { if (n.getText().equals("initial")) return new Color(100, 255, 100); if (n.getChildren().length == 0) return new Color(255, 100, 100); return new Color(100, 100, 255); } }); //Labels vertices with node text. vv.getRenderContext().setVertexLabelTransformer(new Transformer<DialogNode, String>() { @Override public String transform(DialogNode n) { return n.getText().split(" ")[0]; } }); //Draws shape of vertices according to player or non-player status. vv.getRenderContext().setVertexShapeTransformer(new Transformer<DialogNode, Shape>() { @Override public Shape transform(DialogNode n) { if (n.getIsNPC()) return new Rectangle(-15, -15, 30, 30); else return new Ellipse2D.Double(-15.0, -15.0, 30.0, 30.0); } }); //Labels edges with probability of child being selected under the current strategy. vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Double, String>() { @Override public String transform(Double e) { DialogNode source = g.getSource(e); if (source.getProbSets().size() > 0) for (int c = 0; c < source.getChildren().length; c++) if (source.getChildren()[c].equals(g.getDest(e))) { if (source.getProbSets().get(strategy) != null) return Double.toString(source.getProbSets().get(strategy)[c]); else //If node does not have probSet for that strategy, default to strategy 0. return Double.toString(source.getProbSets().get(0)[c]); } return null; } }); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); //Routines for editing mode. EditingModalGraphMouse<DialogNode, Double> gm = new EditingModalGraphMouse<DialogNode, Double>( vv.getRenderContext(), //Runs when a new node is created. new Factory<DialogNode>() { @Override public DialogNode create() { DialogNode n = new DialogNode(isNPCBoxChecked, textField.getText(), new ArrayList<double[]>(), new DialogNode[0]); dg.addNode(n); return n; } }, //Runs when a new edge is created. new Factory<Double>() { @Override public Double create() { addedEdgeID = Math.random(); return addedEdgeID; } }); vv.setGraphMouse(gm); //Frame and mode menu. JMenuBar menuBar = new JMenuBar(); JMenu modeMenu = gm.getModeMenu(); modeMenu.setText("Mouse Mode"); modeMenu.setIcon(null); modeMenu.setPreferredSize(new Dimension(100, 20)); menuBar.add(modeMenu); frame.setJMenuBar(menuBar); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); frame.pack(); frame.setVisible(true); // //Sets position of each node. // for (DialogNode n : nodeMap.values()) { // Point2D.Double point = new Point2D.Double(n.getX(), n.getY()); // if (point.x != 0.0 && point.y != 0.0) // layout.setLocation(n, point); // } }
From source file:MainClass.java
public MainClass() { JFrame frame = new JFrame(); textPane = new JTextPane(); JScrollPane scrollPane = new JScrollPane(textPane); JPanel north = new JPanel(); JButton print = new JButton("Print"); print.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { paintToPDF(textPane);//from w w w . j a v a 2 s. c om } }); JMenuBar menu = new JMenuBar(); JMenu styleMenu = new JMenu(); styleMenu.setText("Style"); Action boldAction = new BoldAction(); boldAction.putValue(Action.NAME, "Bold"); styleMenu.add(boldAction); Action italicAction = new ItalicAction(); italicAction.putValue(Action.NAME, "Italic"); styleMenu.add(italicAction); menu.add(styleMenu); north.add(menu); north.add(print); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(north, BorderLayout.NORTH); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(800, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:MainClass.java
public MainClass() { JFrame frame = new JFrame(); JTextPane textPane = new JTextPane(); JScrollPane scrollPane = new JScrollPane(textPane); JPanel north = new JPanel(); JMenuBar menu = new JMenuBar(); JMenu styleMenu = new JMenu(); styleMenu.setText("Style"); Action boldAction = new BoldAction(); boldAction.putValue(Action.NAME, "Bold"); styleMenu.add(boldAction);//w ww . j a v a 2 s. co m Action italicAction = new ItalicAction(); italicAction.putValue(Action.NAME, "Italic"); styleMenu.add(italicAction); Action foregroundAction = new ForegroundAction(); foregroundAction.putValue(Action.NAME, "Color"); styleMenu.add(foregroundAction); Action formatTextAction = new FontAndSizeAction(); formatTextAction.putValue(Action.NAME, "Font and Size"); styleMenu.add(formatTextAction); menu.add(styleMenu); north.add(menu); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(north, BorderLayout.NORTH); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(800, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:org.sbml.bargraph.MainWindow.java
/** * Set up menus when running under Windows. *//*from www.j a v a 2 s. c o m*/ public void registerForEvents() { Log.note("Setting up the Windows menus."); JMenuItem fileExitItem = new JMenuItem(); fileExitItem .setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, shortcutKeyMask)); fileExitItem.setMnemonic(java.awt.event.KeyEvent.VK_C); fileExitItem.setText("Exit"); fileExitItem.setToolTipText("Exit application"); fileExitItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { quit(); } }); fileMenu.addSeparator(); fileMenu.add(fileExitItem); JMenu helpMenu = new JMenu(); helpMenu.setText("Help"); JMenuItem aboutMenuItem = new JMenuItem(); aboutMenuItem.setText("About " + Config.APP_NAME); aboutMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { about(); } }); helpMenu.add(aboutMenuItem); menuBar.add(helpMenu); }
From source file:com.googlecode.bpmn_simulator.gui.BPMNSimulatorFrame.java
@Override protected JMenu createWindowMenu() { final JMenu menuWindow = new JMenu(Messages.getString("Menu.windows")); //$NON-NLS-1$ final JMenuItem menuWindowElements = new JMenuItem(Messages.getString("Menu.elements")); //$NON-NLS-1$ menuWindowElements.setMnemonic(KeyEvent.VK_E); menuWindowElements.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK)); menuWindowElements.addActionListener(new ActionListener() { @Override//from w w w. j a v a2s.c o m public void actionPerformed(final ActionEvent e) { showElementsFrame(); } }); menuWindow.add(menuWindowElements); final JMenuItem menuWindowInstances = new JMenuItem(Messages.getString("Menu.instances")); //$NON-NLS-1$ menuWindowInstances.setMnemonic(KeyEvent.VK_I); menuWindowInstances.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.ALT_MASK)); menuWindowInstances.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { showInstancesFrame(); } }); menuWindow.add(menuWindowInstances); final JMenu menuWindowDiagram = super.createWindowMenu(); menuWindowDiagram.setText(Messages.getString("Menu.diagrams")); menuWindow.add(menuWindowDiagram); return menuWindow; }
From source file:blue.automation.AutomationManager.java
private JMenu buildChannelMenu(Channel channel, SoundLayer soundLayer) { JMenu retVal = new JMenu(); retVal.setText(channel.getName()); ParameterIdList paramIdList = soundLayer.getAutomationParameters(); // pre effects EffectsChain preEffects = channel.getPreEffects(); if (preEffects.size() > 0) { JMenu preMenu = new JMenu("Pre-Effects"); retVal.add(preMenu);// w w w .j av a2s. c om for (int i = 0; i < preEffects.size(); i++) { Automatable automatable = (Automatable) preEffects.getElementAt(i); ParameterList params = automatable.getParameterList(); if (params.size() > 0) { JMenu effectMenu = new JMenu(); if (automatable instanceof Effect) { effectMenu.setText(((Effect) automatable).getName()); } else if (automatable instanceof Send) { effectMenu.setText("Send: " + ((Send) automatable).getSendChannel()); } else { effectMenu.setText("ERROR"); } preMenu.add(effectMenu); for (int j = 0; j < params.size(); j++) { Parameter param = params.getParameter(j); JMenuItem paramItem = new JMenuItem(); paramItem.setText(param.getName()); paramItem.addActionListener(parameterActionListener); if (param.isAutomationEnabled()) { if (paramIdList.contains(param.getUniqueId())) { paramItem.setForeground(Color.GREEN); } else { paramItem.setForeground(Color.ORANGE); } } paramItem.putClientProperty("param", param); effectMenu.add(paramItem); } } } } // volume JMenuItem volItem = new JMenuItem("Volume"); Parameter volParam = channel.getLevelParameter(); volItem.putClientProperty("param", volParam); volItem.addActionListener(parameterActionListener); if (volParam.isAutomationEnabled()) { if (paramIdList.contains(volParam.getUniqueId())) { volItem.setForeground(Color.GREEN); } else { volItem.setForeground(Color.ORANGE); } } retVal.add(volItem); // post effects EffectsChain postEffects = channel.getPostEffects(); if (postEffects.size() > 0) { JMenu postMenu = new JMenu("Post-Effects"); retVal.add(postMenu); for (int i = 0; i < postEffects.size(); i++) { Automatable automatable = (Automatable) postEffects.getElementAt(i); ParameterList params = automatable.getParameterList(); if (params.size() > 0) { JMenu effectMenu = new JMenu(); if (automatable instanceof Effect) { effectMenu.setText(((Effect) automatable).getName()); } else if (automatable instanceof Send) { effectMenu.setText("Send: " + ((Send) automatable).getSendChannel()); } else { effectMenu.setText("ERROR"); } postMenu.add(effectMenu); for (int j = 0; j < params.size(); j++) { Parameter param = params.getParameter(j); JMenuItem paramItem = new JMenuItem(); paramItem.setText(param.getName()); paramItem.addActionListener(parameterActionListener); if (param.isAutomationEnabled()) { if (paramIdList.contains(param.getUniqueId())) { paramItem.setForeground(Color.GREEN); } else { paramItem.setForeground(Color.ORANGE); } } paramItem.putClientProperty("param", param); effectMenu.add(paramItem); } } } } return retVal; }