List of usage examples for javax.swing JMenu addSeparator
public void addSeparator()
From source file:processing.app.Editor.java
protected void buildSketchMenu(JMenu sketchMenu) { sketchMenu.removeAll();/*from w ww. j a v a2s . c o m*/ JMenuItem item = newJMenuItem(_("Verify / Compile"), 'R'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleRun(false, Editor.this.presentHandler, Editor.this.runHandler); } }); sketchMenu.add(item); item = newJMenuItem(_("Upload"), 'U'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleExport(false); } }); sketchMenu.add(item); item = newJMenuItemShift(_("Upload Using Programmer"), 'U'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleExport(true); } }); sketchMenu.add(item); item = newJMenuItemAlt(_("Export compiled Binary"), 'S'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleRun(false, new ShouldSaveReadOnly(), Editor.this.presentAndSaveHandler, Editor.this.runAndSaveHandler); } }); sketchMenu.add(item); // item = new JMenuItem("Stop"); // item.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // handleStop(); // } // }); // sketchMenu.add(item); sketchMenu.addSeparator(); item = newJMenuItem(_("Show Sketch Folder"), 'K'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.openFolder(sketch.getFolder()); } }); sketchMenu.add(item); item.setEnabled(Base.openFolderAvailable()); if (importMenu == null) { importMenu = new JMenu(_("Include Library")); MenuScroller.setScrollerFor(importMenu); base.rebuildImportMenu(importMenu); } sketchMenu.add(importMenu); item = new JMenuItem(_("Add File...")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { sketch.handleAddFile(); } }); sketchMenu.add(item); }
From source file:processing.app.Editor.java
protected void addTools(JMenu menu, File sourceFolder) { if (sourceFolder == null) return;// ww w. ja v a 2s. c om Map<String, JMenuItem> toolItems = new HashMap<String, JMenuItem>(); File[] folders = sourceFolder.listFiles(new FileFilter() { public boolean accept(File folder) { if (folder.isDirectory()) { //System.out.println("checking " + folder); File subfolder = new File(folder, "tool"); return subfolder.exists(); } return false; } }); if (folders == null || folders.length == 0) { return; } for (int i = 0; i < folders.length; i++) { File toolDirectory = new File(folders[i], "tool"); try { // add dir to classpath for .classes //urlList.add(toolDirectory.toURL()); // add .jar files to classpath File[] archives = toolDirectory.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return (name.toLowerCase().endsWith(".jar") || name.toLowerCase().endsWith(".zip")); } }); URL[] urlList = new URL[archives.length]; for (int j = 0; j < urlList.length; j++) { urlList[j] = archives[j].toURI().toURL(); } URLClassLoader loader = new URLClassLoader(urlList); String className = null; for (int j = 0; j < archives.length; j++) { className = findClassInZipFile(folders[i].getName(), archives[j]); if (className != null) break; } /* // Alternatively, could use manifest files with special attributes: // http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html // Example code for loading from a manifest file: // http://forums.sun.com/thread.jspa?messageID=3791501 File infoFile = new File(toolDirectory, "tool.txt"); if (!infoFile.exists()) continue; String[] info = PApplet.loadStrings(infoFile); //Main-Class: org.poo.shoe.AwesomerTool //String className = folders[i].getName(); String className = null; for (int k = 0; k < info.length; k++) { if (info[k].startsWith(";")) continue; String[] pieces = PApplet.splitTokens(info[k], ": "); if (pieces.length == 2) { if (pieces[0].equals("Main-Class")) { className = pieces[1]; } } } */ // If no class name found, just move on. if (className == null) continue; Class<?> toolClass = Class.forName(className, true, loader); final Tool tool = (Tool) toolClass.newInstance(); tool.init(Editor.this); String title = tool.getMenuTitle(); JMenuItem item = new JMenuItem(title); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(tool); //new Thread(tool).start(); } }); //menu.add(item); toolItems.put(title, item); } catch (Exception e) { e.printStackTrace(); } } ArrayList<String> toolList = new ArrayList<String>(toolItems.keySet()); if (toolList.size() == 0) return; menu.addSeparator(); Collections.sort(toolList); for (String title : toolList) { menu.add((JMenuItem) toolItems.get(title)); } }
From source file:processing.app.Editor.java
protected JMenu buildHelpMenu() { // To deal with a Mac OS X 10.5 bug, add an extra space after the name // so that the OS doesn't try to insert its slow help menu. JMenu menu = new JMenu(_("Help")); JMenuItem item;/*from w w w . j a v a 2 s .c o m*/ /* // testing internal web server to serve up docs from a zip file item = new JMenuItem("Web Server Test"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //WebServer ws = new WebServer(); SwingUtilities.invokeLater(new Runnable() { public void run() { try { int port = WebServer.launch("/Users/fry/coconut/processing/build/shared/reference.zip"); Base.openURL("http://127.0.0.1:" + port + "/reference/setup_.html"); } catch (IOException e1) { e1.printStackTrace(); } } }); } }); menu.add(item); */ /* item = new JMenuItem("Browser Test"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //Base.openURL("http://processing.org/learning/gettingstarted/"); //JFrame browserFrame = new JFrame("Browser"); BrowserStartup bs = new BrowserStartup("jar:file:/Users/fry/coconut/processing/build/shared/reference.zip!/reference/setup_.html"); bs.initUI(); bs.launch(); } }); menu.add(item); */ item = new JMenuItem(_("Getting Started")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.showArduinoGettingStarted(); } }); menu.add(item); item = new JMenuItem(_("Environment")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.showEnvironment(); } }); menu.add(item); item = new JMenuItem(_("Troubleshooting")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.showTroubleshooting(); } }); menu.add(item); item = new JMenuItem(_("Reference")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.showReference(); } }); menu.add(item); menu.addSeparator(); item = new JMenuItem(_("Galileo Help")); item.setEnabled(false); menu.add(item); item = new JMenuItem(_("Getting Started")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.showReference("reference/Galileo_help_files", "ArduinoIDE_guide_galileo"); } }); menu.add(item); item = new JMenuItem(_("Troubleshooting")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.showReference("reference/Galileo_help_files", "Guide_Troubleshooting_Galileo"); ; } }); menu.add(item); menu.addSeparator(); item = new JMenuItem(_("Edison Help")); item.setEnabled(false); menu.add(item); item = new JMenuItem(_("Getting Started")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.showReference("reference/Edison_help_files", "ArduinoIDE_guide_edison"); } }); menu.add(item); item = new JMenuItem(_("Troubleshooting")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.showReference("reference/Edison_help_files", "Guide_Troubleshooting_Edison"); ; } }); menu.add(item); menu.addSeparator(); item = newJMenuItemShift(_("Find in Reference"), 'F'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // if (textarea.isSelectionActive()) { // handleFindReference(); // } handleFindReference(); } }); menu.add(item); item = new JMenuItem(_("Frequently Asked Questions")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.showFAQ(); } }); menu.add(item); item = new JMenuItem(_("Visit Arduino.cc")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.openURL(_("http://www.arduino.cc/")); } }); menu.add(item); // macosx already has its own about menu if (!OSUtils.isMacOS()) { menu.addSeparator(); item = new JMenuItem(_("About Arduino")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { base.handleAbout(); } }); menu.add(item); } return menu; }
From source file:processing.app.Editor.java
protected JMenu buildEditMenu() { JMenu menu = new JMenu(_("Edit")); menu.setName("menuEdit"); undoItem = newJMenuItem(_("Undo"), 'Z'); undoItem.setName("menuEditUndo"); undoItem.addActionListener(undoAction = new UndoAction()); menu.add(undoItem);/* w w w . j a v a2s . c o m*/ if (!OSUtils.isMacOS()) { redoItem = newJMenuItem(_("Redo"), 'Y'); } else { redoItem = newJMenuItemShift(_("Redo"), 'Z'); } redoItem.setName("menuEditRedo"); redoItem.addActionListener(redoAction = new RedoAction()); menu.add(redoItem); menu.addSeparator(); // TODO "cut" and "copy" should really only be enabled // if some text is currently selected JMenuItem cutItem = newJMenuItem(_("Cut"), 'X'); cutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleCut(); } }); menu.add(cutItem); JMenuItem copyItem = newJMenuItem(_("Copy"), 'C'); copyItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.copy(); } }); menu.add(copyItem); JMenuItem copyForumItem = newJMenuItemShift(_("Copy for Forum"), 'C'); copyForumItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // SwingUtilities.invokeLater(new Runnable() { // public void run() { new DiscourseFormat(Editor.this, false).show(); // } // }); } }); menu.add(copyForumItem); JMenuItem copyHTMLItem = newJMenuItemAlt(_("Copy as HTML"), 'C'); copyHTMLItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // SwingUtilities.invokeLater(new Runnable() { // public void run() { new DiscourseFormat(Editor.this, true).show(); // } // }); } }); menu.add(copyHTMLItem); JMenuItem pasteItem = newJMenuItem(_("Paste"), 'V'); pasteItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.paste(); sketch.setModified(true); } }); menu.add(pasteItem); JMenuItem selectAllItem = newJMenuItem(_("Select All"), 'A'); selectAllItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.selectAll(); } }); menu.add(selectAllItem); menu.addSeparator(); JMenuItem commentItem = newJMenuItem(_("Comment/Uncomment"), '/'); commentItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleCommentUncomment(); } }); menu.add(commentItem); JMenuItem increaseIndentItem = new JMenuItem(_("Increase Indent")); increaseIndentItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)); increaseIndentItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(true); } }); menu.add(increaseIndentItem); JMenuItem decreseIndentItem = new JMenuItem(_("Decrease Indent")); decreseIndentItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK)); decreseIndentItem.setName("menuDecreaseIndent"); decreseIndentItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(false); } }); menu.add(decreseIndentItem); menu.addSeparator(); JMenuItem findItem = newJMenuItem(_("Find..."), 'F'); findItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (find == null) { find = new FindReplace(Editor.this); } if (!OSUtils.isMacOS()) { find.setFindText(getSelectedText()); } find.setLocationRelativeTo(Editor.this); find.setVisible(true); } }); menu.add(findItem); JMenuItem findNextItem = newJMenuItem(_("Find Next"), 'G'); findNextItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (find != null) { find.findNext(); } } }); menu.add(findNextItem); JMenuItem findPreviousItem = newJMenuItemShift(_("Find Previous"), 'G'); findPreviousItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (find != null) { find.findPrevious(); } } }); menu.add(findPreviousItem); if (OSUtils.isMacOS()) { JMenuItem useSelectionForFindItem = newJMenuItem(_("Use Selection For Find"), 'E'); useSelectionForFindItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (find == null) { find = new FindReplace(Editor.this); } find.setFindText(getSelectedText()); } }); menu.add(useSelectionForFindItem); } return menu; }
From source file:sc.fiji.kappa.gui.KappaMenuBar.java
/** * Creates a menu-bar and adds menu items to it *//*from ww w . j a v a2s . co m*/ public KappaMenuBar(Context context, KappaFrame frame) { context.inject(this); this.frame = frame; // File chooser for curve data FileNameExtensionFilter kappaFilter = new FileNameExtensionFilter("Kappa Files", "kapp"); kappaLoad = new JFileChooser(); kappaLoad.setFileFilter(kappaFilter); kappaLoad.setDialogTitle("Load Existing Curve Data"); kappaSave = new JFileChooser(); kappaSave.setFileFilter(kappaFilter); kappaSave.setDialogTitle("Save Curve Data"); // Declares the file menu JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); /* * // Menu Items for file operations // Creates a new file chooser. Same native * image support as ImageJ since ImageJ // libraries are used. kappaOpen = new * JFileChooser(); FileNameExtensionFilter filter = new * FileNameExtensionFilter("Image Files", "tif", "tiff", "jpeg", "jpg", "bmp", * "fits", "pgm", "ppm", "pbm", "gif", "png", "dic", "dcm", "dicom", "lsm", * "avi"); kappaOpen.setFileFilter(filter); * * JMenuItem openMenu = new JMenuItem("Open Image File"); * openMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, DEFAULT_MASK)); * openMenu.addActionListener(e -> { int returnVal = * kappaOpen.showOpenDialog(this.frame); if (returnVal == * JFileChooser.APPROVE_OPTION) { openImageFile(kappaOpen.getSelectedFile()); } * }); fileMenu.add(openMenu); */ JMenuItem openActiveMenu = new JMenuItem("Open Active Image"); openActiveMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, DEFAULT_MASK)); openActiveMenu.addActionListener(e -> { openActiveImage(context); }); fileMenu.add(openActiveMenu); fileMenu.addSeparator(); JMenuItem importROIsAsCurvesMenu = new JMenuItem("Import ROIs as curves"); importROIsAsCurvesMenu.addActionListener(e -> { importROIsAsCurves(context); }); fileMenu.add(importROIsAsCurvesMenu); fileMenu.addSeparator(); JMenuItem loadMenu = new JMenuItem("Load Curve Data"); loadMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MASK)); loadMenu.addActionListener(e -> { // Handle open button action. int returnVal = kappaLoad.showOpenDialog(this.frame); if (returnVal == JFileChooser.APPROVE_OPTION) { file = kappaLoad.getSelectedFile(); loadCurveFile(file); } }); fileMenu.add(loadMenu); JMenuItem saveMenu = new JMenuItem("Save Curve Data"); saveMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, DEFAULT_MASK)); saveMenu.addActionListener(e -> { String dirPath = frame.getImageStack().getOriginalFileInfo().directory; if (dirPath != null) { String kappaPath = FilenameUtils .removeExtension(frame.getImageStack().getOriginalFileInfo().fileName); kappaPath += ".kapp"; File fullPath = new File(dirPath, kappaPath); kappaSave.setSelectedFile(fullPath); } // Handles save button action. int returnVal = kappaSave.showSaveDialog(this.frame); if (returnVal == JFileChooser.APPROVE_OPTION) { file = kappaSave.getSelectedFile(); // Appends a .kapp if (!file.getPath().toLowerCase().endsWith(".kapp")) { file = new File(file.getPath() + ".kapp"); } saveCurveFile(file); } }); fileMenu.add(saveMenu); this.add(fileMenu); // Menu Items for all the tools JMenu toolMenu = new JMenu("Tools"); for (int i = 0; i < ToolPanel.NO_TOOLS; i++) { toolMenuItems[i] = new JMenuItem(ToolPanel.TOOL_MENU_NAMES[i]); toolMenuItems[i].setEnabled(false); toolMenuItems[i].setAccelerator(KeyStroke.getKeyStroke(ToolPanel.TOOL_MNEMONICS[i], 0)); final int j = i; toolMenuItems[i].addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { frame.getToolPanel().setSelected(j, true); frame.getScrollPane().setCursor(ToolPanel.TOOL_CURSORS[j]); } }); toolMenu.add(toolMenuItems[i]); } // We also add a menu item for deleting Bezier Curves via the Backspace key. setDelete(new JMenuItem("Delete Curves")); getDelete().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { frame.deleteCurve(); } }); getDelete().setEnabled(false); getDelete().setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); toolMenu.addSeparator(); toolMenu.add(getDelete()); setEnter(new JMenuItem("Enter Curve")); getEnter().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { frame.enterCurve(); } }); getEnter().setEnabled(false); getEnter().setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)); toolMenu.add(getEnter()); fit = new JMenuItem("Fit Curve"); fit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { frame.fitCurves(); } }); fit.setEnabled(false); fit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, 0)); toolMenu.add(fit); toolMenu.addSeparator(); // TODO remove this later // JMenuItem runTestScript = new JMenuItem ("Run Testing Script"); // runTestScript.addActionListener (new ActionListener(){ // public void actionPerformed (ActionEvent event){ // try{frame.testingScript();} // catch(IOException e){System.out.println("Script Error");} // }}); // runTestScript.setAccelerator (KeyStroke.getKeyStroke(KeyEvent.VK_S, 0)); // toolMenu.add(runTestScript); JCheckBoxMenuItem toggleCtrlPtAdjustment = new JCheckBoxMenuItem("Enable Control Point Adjustment"); toggleCtrlPtAdjustment.setState(frame.isEnableCtrlPtAdjustment()); toggleCtrlPtAdjustment.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame.setEnableCtrlPtAdjustment(!frame.isEnableCtrlPtAdjustment()); ; } }); toggleCtrlPtAdjustment.setEnabled(true); toolMenu.add(toggleCtrlPtAdjustment); this.add(toolMenu); // Navigation Menu // TODO FIX action listeners to these. JMenu navigateMenu = new JMenu("Navigate"); prevFrame = new JMenuItem("Previous Frame"); nextFrame = new JMenuItem("Next Frame"); prevKeyframe = new JMenuItem("Previous Keyframe"); nextKeyframe = new JMenuItem("Next Keyframe"); prevFrame.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK)); nextFrame.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.ALT_MASK)); prevKeyframe.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, DEFAULT_MASK)); nextKeyframe.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, DEFAULT_MASK)); prevFrame.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { frame.getControlPanel().getCurrentLayerSlider() .setValue(Math.max(frame.getControlPanel().getCurrentLayerSlider().getValue() - 1, frame.getControlPanel().getCurrentLayerSlider().getMinimum())); } }); nextFrame.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { frame.getControlPanel().getCurrentLayerSlider() .setValue(Math.min(frame.getControlPanel().getCurrentLayerSlider().getValue() + 1, frame.getControlPanel().getCurrentLayerSlider().getMaximum())); } }); prevKeyframe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { } }); nextKeyframe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { } }); prevFrame.setEnabled(false); nextFrame.setEnabled(false); prevKeyframe.setEnabled(false); nextKeyframe.setEnabled(false); navigateMenu.add(prevFrame); navigateMenu.add(nextFrame); navigateMenu.add(prevKeyframe); navigateMenu.add(nextKeyframe); this.add(navigateMenu); // Image options. JMenu imageMenu = new JMenu("Image"); // Brightness and Contrast tool. Taken from ImageJ. adjustBrightnessContrast = new JMenuItem("Adjust Brightness/Contrast"); adjustBrightnessContrast.setEnabled(false); adjustBrightnessContrast.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ContrastAdjuster c = new ContrastAdjuster(frame); c.run("Brightness/Contrast...[C]"); } }); imageMenu.add(adjustBrightnessContrast); this.add(imageMenu); // Zoom-In and Zoom-Out Commands JMenu viewMenu = new JMenu("View"); zoomIn = new JMenuItem("Zoom In"); zoomOut = new JMenuItem("Zoom Out"); zoomIn.addActionListener(new ZoomInListener(frame.getControlPanel())); zoomOut.addActionListener(new ZoomOutListener(frame.getControlPanel())); zoomIn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, DEFAULT_MASK)); zoomOut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, DEFAULT_MASK)); zoomIn.setEnabled(false); zoomOut.setEnabled(false); // Menu Item for showing bounding boxes setBoundingBoxMenu(new JCheckBoxMenuItem("Show Bounding Boxes")); getBoundingBoxMenu().setState(false); getBoundingBoxMenu().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { frame.drawImageOverlay(); } }); getBoundingBoxMenu().setEnabled(false); // Menu Item for choosing the x-axis values for the curvature and intensity // display // For instance, you can display x vs. curvature, or current arc length vs // curvature, or the point index vs curvature // The default is the point index. distributionDisplay = DEFAULT_DISTRIBUTION_DISPLAY; JMenu xAxisSubmenu = new JMenu("Curve Distribution X-Axis:"); ButtonGroup xAxisGroup = new ButtonGroup(); JMenuItem xValue = new JCheckBoxMenuItem("X-Coordinate"); JMenuItem curveLength = new JCheckBoxMenuItem("Arc Length"); JMenuItem pointIndex = new JCheckBoxMenuItem("Point Index"); xAxisGroup.add(xValue); xAxisGroup.add(curveLength); xAxisGroup.add(pointIndex); xAxisSubmenu.add(xValue); xAxisSubmenu.add(curveLength); xAxisSubmenu.add(pointIndex); xValue.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { distributionDisplay = 0; frame.getInfoPanel().updateHistograms(); } }); curveLength.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { distributionDisplay = 1; frame.getInfoPanel().updateHistograms(); } }); pointIndex.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { distributionDisplay = 2; frame.getInfoPanel().updateHistograms(); } }); if (DEFAULT_DISTRIBUTION_DISPLAY == 0) { xValue.setSelected(true); } else if (DEFAULT_DISTRIBUTION_DISPLAY == 1) { curveLength.setSelected(true); } else { pointIndex.setSelected(true); } // Menu Item for scaling curve strokes when zooming in or out setScaleCurvesMenu(new JCheckBoxMenuItem("Scale Curve Strokes")); getScaleCurvesMenu().setState(true); getScaleCurvesMenu().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { frame.drawImageOverlay(); } }); getScaleCurvesMenu().setEnabled(false); // Menu Item for image antialiasing setAntialiasingMenu(new JCheckBoxMenuItem("Enable Antialiasing")); getAntialiasingMenu().setState(false); getAntialiasingMenu().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { frame.setScaledImage(frame.getControlPanel().getScaleSlider().getValue() / 100.0); frame.drawImageOverlay(); } }); getAntialiasingMenu().setEnabled(false); // Menu Item for displaying tangent and normal curves. setTangentMenu(new JCheckBoxMenuItem("Show Tangent and Normal Vectors")); getTangentMenu().setState(false); getTangentMenu().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { frame.drawImageOverlay(); } }); getTangentMenu().setEnabled(false); viewMenu.add(zoomIn); viewMenu.add(zoomOut); viewMenu.addSeparator(); viewMenu.add(xAxisSubmenu); viewMenu.addSeparator(); viewMenu.add(getScaleCurvesMenu()); viewMenu.add(getTangentMenu()); viewMenu.add(getBoundingBoxMenu()); viewMenu.add(getAntialiasingMenu()); this.add(viewMenu); // Sets a "Help" menu list JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('H'); // Adds an "About" option to the menu list JMenuItem aboutMenuItem = new JMenuItem("About...", 'A'); aboutMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JOptionPane.showMessageDialog(frame, "Developed by the Brouhard lab, 2016-2017.", KappaFrame.APPLICATION_NAME, JOptionPane.INFORMATION_MESSAGE); } }); // Adds a link to the User Manual JMenuItem userManualLink = new JMenuItem("User Manual"); userManualLink.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(new URI( "https://dl.dropboxusercontent.com/u/157117/KappaFrame%20User%20Manual.pdf")); } } catch (Exception e) { System.out.println("Incorrect URL Syntax"); } ; } }); // Adds all newly created menu items to the "Help" list helpMenu.add(userManualLink); helpMenu.add(aboutMenuItem); this.add(helpMenu); }
From source file:simplesqlformatter.formatter.SQLFormatterEditor.java
private void createEditMenu(JMenuBar menuBar, JToolBar toolBar) { final JMenu menuEdit = new JMenu("Edit"); final GuiAction copy = new GuiAction("Copy All", "/icons/edit_copy.gif"); copy.setShortcutKey(KeyStroke.getKeyStroke("control C")); copy.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent actionevent) { copy();// www . j a v a2s .c om } }); menuEdit.add(copy); final GuiAction paste = new GuiAction("Paste Over", "/icons/edit_paste.gif"); paste.setShortcutKey(KeyStroke.getKeyStroke("control shift V")); paste.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent actionevent) { clear(); paste(); } }); menuEdit.add(paste); final GuiAction copyAsJavaString = new GuiAction("Copy as Java String", "/icons/edit_copy.gif"); copyAsJavaString.setShortcutKey(KeyStroke.getKeyStroke("control J")); copyAsJavaString.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent actionevent) { copyAsJavaString(); } }); menuEdit.add(copyAsJavaString); menuEdit.addSeparator(); final GuiAction format = new GuiAction("Format", "/icons/edit_format.gif"); format.setShortcutKey(KeyStroke.getKeyStroke("control F")); format.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent actionevent) { format(); } }); menuEdit.add(format); toolBar.add(format); final GuiAction formatFromClipboard = new GuiAction("Format From Clipboard", "/icons/edit_format_from_clipboard.gif"); formatFromClipboard.setShortcutKey(KeyStroke.getKeyStroke("control shift F")); formatFromClipboard.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent actionevent) { formatFromClipboard(); } }); menuEdit.add(formatFromClipboard); toolBar.add(formatFromClipboard); menuBar.add(menuEdit); }
From source file:simplesqlformatter.formatter.SQLFormatterEditor.java
private void createFileMenu(JMenuBar menuBar, JToolBar toolBar) { final JMenu menuFile = new JMenu("File"); final GuiAction newFile = new GuiAction("New", "/icons/file_new.gif"); newFile.setShortcutKey(KeyStroke.getKeyStroke("control N")); newFile.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent actionevent) { clear();/*from w w w.ja v a 2 s . co m*/ } }); menuFile.add(newFile); toolBar.add(newFile); final GuiAction openFile = new GuiAction("Open", "/icons/file_open.gif"); openFile.setShortcutKey(KeyStroke.getKeyStroke("control O")); openFile.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent actionevent) { openFile(); } }); menuFile.add(openFile); toolBar.add(openFile); final GuiAction saveFile = new GuiAction("Save", "/icons/file_save.gif"); saveFile.setShortcutKey(KeyStroke.getKeyStroke("control S")); saveFile.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent actionevent) { saveFile(); } }); menuFile.add(saveFile); toolBar.add(saveFile); menuFile.addSeparator(); toolBar.addSeparator(); final ExitAction exit = new ExitAction(this, "Exit"); exit.setShortcutKey(KeyStroke.getKeyStroke("control Q")); menuFile.add(exit); menuBar.add(menuFile); }
From source file:us.daveread.basicquery.BasicQuery.java
/** * File menu setup// w w w . j ava2s . c om * * @return The file menu */ private JMenu fileMenu() { JMenu menu; // File Menu menu = new JMenu(Resources.getString("mnuFileLabel")); menu.setMnemonic(Resources.getChar("mnuFileAccel")); menu.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuFileDesc")); // File | Open SQL File fileOpenSQL = new JMenuItem(Resources.getString("mnuFileOpenLabel")); fileOpenSQL.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuFileOpenAccel"), ActionEvent.ALT_MASK)); fileOpenSQL.setMnemonic(Resources.getChar("mnuFileOpenAccel")); fileOpenSQL.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuFileOpenDesc")); fileOpenSQL.addActionListener(this); fileOpenSQL.setEnabled(true); menu.add(fileOpenSQL); menu.addSeparator(); // File | Log Stats fileLogStats = new JCheckBoxMenuItem(Resources.getString("mnuFileLogStatsLabel")); fileLogStats.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuFileLogStatsAccel"), ActionEvent.ALT_MASK)); fileLogStats.setMnemonic(Resources.getChar("mnuFileLogStatsAccel")); fileLogStats.getAccessibleContext() .setAccessibleDescription(Resources.getString("mnuFileLogStatsAccel", DBSTATS_NAME)); fileLogStats.setEnabled(true); fileLogStats.setSelected(false); menu.add(fileLogStats); // File | Log Results fileLogResults = new JCheckBoxMenuItem(Resources.getString("mnuFileLogResultsLabel")); fileLogResults.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuFileLogResultsAccel"), ActionEvent.ALT_MASK)); fileLogResults.setMnemonic(Resources.getString("mnuFileLogResultsAccel").charAt(0)); fileLogResults.getAccessibleContext() .setAccessibleDescription(Resources.getString("mnuFileLogResultsDesc", DBRESULTS_NAME)); fileLogResults.setEnabled(true); fileLogResults.setSelected(false); menu.add(fileLogResults); menu.addSeparator(); // File | Export Results As CSV fileSaveAsCSV = new JMenuItem(Resources.getString("mnuFileExportCSVLabel")); fileSaveAsCSV.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuFileExportCSVAccel"), ActionEvent.ALT_MASK)); fileSaveAsCSV.setMnemonic(Resources.getChar("mnuFileExportCSVAccel")); fileSaveAsCSV.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuFileExportCSVDesc")); fileSaveAsCSV.addActionListener(this); fileSaveAsCSV.setEnabled(false); menu.add(fileSaveAsCSV); // File | Export Results As Triples fileSaveAsTriples = new JMenuItem(Resources.getString("mnuFileExportTriplesLabel")); fileSaveAsTriples.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuFileExportTriplesAccel"), ActionEvent.ALT_MASK)); fileSaveAsTriples.setMnemonic(Resources.getChar("mnuFileExportTriplesAccel")); fileSaveAsTriples.getAccessibleContext() .setAccessibleDescription(Resources.getString("mnuFileExportTriplesDesc")); fileSaveAsTriples.addActionListener(new ExportResultsAsTriplesListener()); fileSaveAsTriples.setEnabled(false); menu.add(fileSaveAsTriples); // File | Save BLOBs fileSaveBLOBs = new JMenuItem(Resources.getString("mnuFileSaveBLOBLabel")); fileSaveBLOBs.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuFileSaveBLOBAccel"), ActionEvent.ALT_MASK)); fileSaveBLOBs.setMnemonic(Resources.getChar("mnuFileSaveBLOBAccel")); fileSaveBLOBs.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuFileSaveBLOBDesc")); fileSaveBLOBs.addActionListener(this); fileSaveBLOBs.setEnabled(false); menu.add(fileSaveBLOBs); menu.addSeparator(); // File | Raw Export fileExportsRaw = new JCheckBoxMenuItem(Resources.getString("mnuFileRawExportLabel")); fileExportsRaw.setMnemonic(Resources.getChar("mnuFileRawExportAccel")); fileExportsRaw.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuFileRawExportDesc")); fileExportsRaw.setEnabled(true); fileExportsRaw.setSelected(false); menu.add(fileExportsRaw); // File | No CR Added to Export fileNoCRAddedToExportRows = new JCheckBoxMenuItem(Resources.getString("mnuFileNoCRLabel")); fileNoCRAddedToExportRows.setMnemonic(Resources.getChar("mnuFileNoCRAccel")); fileNoCRAddedToExportRows.getAccessibleContext() .setAccessibleDescription(Resources.getString("mnuFileNoCRDesc")); fileNoCRAddedToExportRows.setEnabled(true); fileNoCRAddedToExportRows.setSelected(false); menu.add(fileNoCRAddedToExportRows); menu.addSeparator(); fileExit = new JMenuItem(Resources.getString("mnuFileExitLabel")); fileExit.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuFileExitAccel"), ActionEvent.ALT_MASK)); fileExit.setMnemonic(Resources.getChar("mnuFileExitAccel")); fileExit.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuFileExitDesc")); fileExit.addActionListener(this); fileExit.setEnabled(true); menu.add(fileExit); return menu; }
From source file:us.daveread.basicquery.BasicQuery.java
/** * Edit menu setup/* www. ja v a2 s . co m*/ * * @return The edit menu */ private JMenu editMenu() { JMenu menu; // Edit Menu menu = new JMenu(Resources.getString("mnuEditLabel")); menu.setMnemonic(Resources.getChar("mnuEditAccel")); menu.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuEditDesc")); // Edit | Copy editCopy = new JMenuItem(Resources.getString("mnuEditCopyLabel")); editCopy.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuEditCopyAccel"), ActionEvent.ALT_MASK)); editCopy.setMnemonic(Resources.getChar("mnuEditCopyAccel")); editCopy.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuEditCopyDesc")); editCopy.addActionListener(this); editCopy.setEnabled(true); menu.add(editCopy); // Edit | Select All editSelectAll = new JMenuItem(Resources.getString("mnuEditSelectAllLabel")); editSelectAll.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuEditSelectAllAccel"), ActionEvent.ALT_MASK)); editSelectAll.setMnemonic(Resources.getChar("mnuEditSelectAllAccel")); editSelectAll.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuEditSelectAllDesc")); editSelectAll.addActionListener(this); editSelectAll.setEnabled(true); menu.add(editSelectAll); menu.addSeparator(); // Edit | Sort by Selected Columns editSort = new JMenuItem(Resources.getString("mnuEditSortLabel")); editSort.setMnemonic(Resources.getChar("mnuEditSortAccel")); editSort.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuEditSortDesc")); editSort.addActionListener(this); editSort.setEnabled(true); menu.add(editSort); return menu; }
From source file:us.daveread.basicquery.BasicQuery.java
/** * Query menu set//from w ww . j av a 2s . co m * * @return The query menu */ private JMenu queryMenu() { JMenu menu; // Query Menu menu = new JMenu(Resources.getString("mnuQueryLabel")); menu.setMnemonic(Resources.getChar("mnuQueryAccel")); menu.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuQueryDesc")); // Query | Select Statement queryMakeVerboseSelect = new JMenuItem(Resources.getString("mnuQuerySelectLabel")); queryMakeVerboseSelect.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuQuerySelectAccel"), ActionEvent.ALT_MASK)); queryMakeVerboseSelect.setMnemonic(Resources.getChar("mnuQuerySelectAccel")); queryMakeVerboseSelect.getAccessibleContext() .setAccessibleDescription(Resources.getString("mnuQuerySelectDesc")); queryMakeVerboseSelect.addActionListener(this); queryMakeVerboseSelect.setEnabled(true); menu.add(queryMakeVerboseSelect); // Query | Insert Statement queryMakeInsert = new JMenuItem(Resources.getString("mnuQueryInsertLabel")); queryMakeInsert.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuQueryInsertAccel"), ActionEvent.ALT_MASK)); queryMakeInsert.setMnemonic(Resources.getChar("mnuQueryInsertAccel")); queryMakeInsert.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuQueryInsertDesc")); queryMakeInsert.addActionListener(this); queryMakeInsert.setEnabled(true); menu.add(queryMakeInsert); // Query | Update Statement queryMakeUpdate = new JMenuItem(Resources.getString("mnuQueryUpdateLabel")); queryMakeUpdate.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuQueryUpdateAccel"), ActionEvent.ALT_MASK)); queryMakeUpdate.setMnemonic(Resources.getChar("mnuQueryUpdateAccel")); queryMakeUpdate.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuQueryUpdateDesc")); queryMakeUpdate.addActionListener(this); queryMakeUpdate.setEnabled(true); menu.add(queryMakeUpdate); menu.addSeparator(); // Query | Select * querySelectStar = new JMenuItem(Resources.getString("mnuQuerySelectStarLabel")); querySelectStar.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuQuerySelectStarAccel"), ActionEvent.ALT_MASK)); querySelectStar.setMnemonic(Resources.getChar("mnuQuerySelectStarAccel")); querySelectStar.getAccessibleContext() .setAccessibleDescription(Resources.getString("mnuQuerySelectStarDesc")); querySelectStar.addActionListener(this); querySelectStar.setEnabled(true); menu.add(querySelectStar); // Query | Describe Select * queryDescribeStar = new JMenuItem(Resources.getString("mnuQueryDescSelectStarLabel")); queryDescribeStar.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuQueryDescSelectStarAccel"), ActionEvent.ALT_MASK)); queryDescribeStar.setMnemonic(Resources.getChar("mnuQueryDescSelectStarAccel")); queryDescribeStar.getAccessibleContext() .setAccessibleDescription(Resources.getString("mnuQueryDescSelectStarDesc")); queryDescribeStar.addActionListener(this); queryDescribeStar.setEnabled(true); menu.add(queryDescribeStar); menu.addSeparator(); // Query | Reorder Queries querySetOrder = new JMenuItem(Resources.getString("mnuQueryReorderLabel")); querySetOrder.setMnemonic(Resources.getChar("mnuQueryReorderAccel")); querySetOrder.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuQueryReorderDesc")); querySetOrder.addActionListener(this); querySetOrder.setEnabled(true); menu.add(querySetOrder); menu.addSeparator(); // Query | Run All queryRunAll = new JMenuItem(Resources.getString("mnuQueryRunAllLabel")); queryRunAll.setAccelerator( KeyStroke.getKeyStroke(Resources.getChar("mnuQueryRunAllAccel"), ActionEvent.ALT_MASK)); queryRunAll.setMnemonic(Resources.getChar("mnuQueryRunAllAccel")); queryRunAll.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuQueryRunAllDesc")); queryRunAll.addActionListener(this); queryRunAll.setEnabled(true); menu.add(queryRunAll); return menu; }