List of usage examples for java.awt.event KeyEvent VK_S
int VK_S
To view the source code for java.awt.event KeyEvent VK_S.
Click Source Link
From source file:marytts.tools.voiceimport.DatabaseImportMain.java
protected void setupGUI() { // A scroll pane containing one labelled checkbox per component, // and a "run selected components" button below. GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridC = new GridBagConstraints(); getContentPane().setLayout(gridBagLayout); JPanel checkboxPane = new JPanel(); checkboxPane.setLayout(new BoxLayout(checkboxPane, BoxLayout.Y_AXIS)); //checkboxPane.setPreferredSize(new Dimension(300, 300)); int compIndex = 0; for (int j = 0; j < groups2Comps.length; j++) { String[] nextGroup = groups2Comps[j]; JPanel groupPane = new JPanel(); groupPane.setLayout(new BoxLayout(groupPane, BoxLayout.Y_AXIS)); groupPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(nextGroup[0]), BorderFactory.createEmptyBorder(1, 1, 1, 1))); for (int i = 1; i < nextGroup.length; i++) { JButton configButton = new JButton(); Icon configIcon = new ImageIcon(DatabaseImportMain.class.getResource("configure.png"), "Configure"); configButton.setIcon(configIcon); configButton.setPreferredSize(new Dimension(configIcon.getIconWidth(), configIcon.getIconHeight())); configButton.addActionListener(new ConfigButtonActionListener(nextGroup[i])); configButton.setBorderPainted(false); //System.out.println("Adding checkbox for "+components[i].getClass().getName()); checkboxes[compIndex] = new JCheckBox(nextGroup[i]); checkboxes[compIndex].setFocusable(true); //checkboxes[i].setPreferredSize(new Dimension(200, 30)); JPanel line = new JPanel(); line.setLayout(new BorderLayout(5, 0)); line.add(configButton, BorderLayout.WEST); line.add(checkboxes[compIndex], BorderLayout.CENTER); groupPane.add(line);/*from www . j a v a 2s .c o m*/ compIndex++; } checkboxPane.add(groupPane); } gridC.gridx = 0; gridC.gridy = 0; gridC.fill = GridBagConstraints.BOTH; JScrollPane scrollPane = new JScrollPane(checkboxPane); scrollPane.setPreferredSize(new Dimension(450, 300)); gridBagLayout.setConstraints(scrollPane, gridC); getContentPane().add(scrollPane); JButton helpButton = new JButton("Help"); helpButton.setMnemonic(KeyEvent.VK_H); helpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { displayHelpGUI(); } }); JButton settingsButton = new JButton("Settings"); settingsButton.setMnemonic(KeyEvent.VK_S); settingsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { currentComponent = "Global properties"; displaySettingsGUI(); } }); runButton = new JButton("Run"); runButton.setMnemonic(KeyEvent.VK_R); runButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { runSelectedComponents(); } }); JButton quitAndSaveButton = new JButton("Quit"); quitAndSaveButton.setMnemonic(KeyEvent.VK_Q); quitAndSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); gridC.gridy = 1; JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); //buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS)); //runButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(runButton); //helpButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(helpButton); //settingsButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(settingsButton); //buttonPanel.add(Box.createHorizontalGlue()); //quitAndSaveButton.setAlignmentX(JButton.RIGHT_ALIGNMENT); buttonPanel.add(quitAndSaveButton); gridBagLayout.setConstraints(buttonPanel, gridC); getContentPane().add(buttonPanel); //getContentPane().setPreferredSize(new Dimension(300, 300)); // End program when closing window: addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); }
From source file:common.AbstractGUI.java
private void createToolMenu() { toolMenu = new JMenu("Tools"); menuBar.add(toolMenu);//from w w w. j a va 2 s . c o m takeSnapshotMenuItem = new JMenuItem("Take snapshot"); takeSnapshotMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.ALT_MASK)); takeSnapshotMenuItem.addActionListener(snapshotActionListener); toolMenu.add(takeSnapshotMenuItem); }
From source file:bio.gcat.gui.BDATool.java
public BDATool() { super("BDA Tool - " + AnalysisTool.NAME); setIconImage(getImage("bda")); setMinimumSize(new Dimension(660, 400)); setPreferredSize(new Dimension(1020, 400)); setSize(getPreferredSize());/* w w w . j a va 2 s.c o m*/ setLocationByPlatform(true); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); menubar = new JMenuBar(); menu = new JMenu[4]; menubar.add(menu[0] = new JMenu("File")); menubar.add(menu[1] = new JMenu("Edit")); menubar.add(menu[2] = new JMenu("Window")); menubar.add(menu[3] = new JMenu("Help")); setJMenuBar(menubar); menu[0].add(createMenuItem("Open...", "folder-horizontal-open", KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK), ACTION_OPEN, this)); menu[0].add(createMenuItem("Save As...", "disk--arrow", KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK), ACTION_SAVE_AS, this)); menu[0].add(createSeparator()); menu[0].add(createMenuItem("Close Window", "cross", ACTION_CLOSE, this)); menu[1].add(createMenuText("Binary Dichotomic Algorithm:")); menu[1].add(createMenuItem("Add", KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_ADD, this)); menu[1].add(createMenuItem("Edit...", KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_EDIT, this)); menu[1].add( createMenuItem("Remove", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), ACTION_BDA_REMOVE, this)); menu[1].add(createMenuItem("Clear", ACTION_BDAS_CLEAR, this)); menu[1].add(seperateMenuItem(createMenuItem("Move Up", KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_MOVE_UP, this))); menu[1].add(createMenuItem("Move Down", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_MOVE_DOWN, this)); menu[2].add(createMenuItem("Preferences", ACTION_PREFERENCES, this)); menu[3].add(createMenuItem("About BDA Tool", "bda", ACTION_ABOUT, this)); for (String action : new String[] { ACTION_BDA_EDIT, ACTION_BDA_REMOVE, ACTION_BDAS_CLEAR, ACTION_BDA_MOVE_UP, ACTION_BDA_MOVE_DOWN }) getMenuItem(menubar, action).setEnabled(false); getMenuItem(menubar, ACTION_PREFERENCES).setEnabled(false); registerKeyStroke(getRootPane(), KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "remove", new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (bdaPanel.table.hasFocus()) removeBinaryDichotomicAlgorithm(); } }); toolbar = new JToolBar[1]; toolbar[0] = new JToolBar("File"); toolbar[0].add(createToolbarButton("Open File", "folder-horizontal-open", ACTION_OPEN, this)); toolbar[0].add(createToolbarButton("Save As File", "disk--arrow", ACTION_SAVE_AS, this)); toolbars = new JPanel(new FlowLayout(FlowLayout.LEADING)); for (JToolBar toolbar : toolbar) toolbars.add(toolbar); add(toolbars, BorderLayout.NORTH); add(createSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, true, 360, 0.195, new JScrollPane(bdaPanel = new BinaryDichotomicAlgorithmPanel()), new JScrollPane(tablePanel = new JPanel(new BorderLayout()))), BorderLayout.CENTER); add(bottom = new JPanel(new FlowLayout(FlowLayout.RIGHT)), BorderLayout.SOUTH); status = new JLabel(); status.setBorder(new EmptyBorder(0, 5, 0, 5)); status.setHorizontalAlignment(JLabel.RIGHT); bottom.add(status); ((ListTableModel<?>) bdaPanel.table.getModel()).addListDataListener(this); bdaPanel.table.getSelectionModel().addListSelectionListener(this); revalidateGeneticCodeTable(); }
From source file:org.dishevelled.brainstorm.BrainStorm.java
/** * Initialize components./*from w w w.j av a 2 s . co m*/ */ private void initComponents() { Font font = new Font(chooseFontName(), Font.PLAIN, fontSize); hiddenCursor = createHiddenCursor(); textArea = new JTextArea() { /** {@inheritDoc} */ protected void paintComponent(final Graphics graphics) { Graphics2D g2 = (Graphics2D) graphics; g2.setRenderingHint(KEY_FRACTIONALMETRICS, VALUE_FRACTIONALMETRICS_ON); g2.setRenderingHint(KEY_TEXT_ANTIALIASING, VALUE_TEXT_ANTIALIAS_LCD_HRGB); super.paintComponent(g2); } }; textArea.setFont(font); textArea.setOpaque(true); textArea.setCursor(hiddenCursor); textArea.setBackground(backgroundColor); textArea.setForeground(textColor); textArea.setRows(rows); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); // clear all input mappings InputMap inputMap = textArea.getInputMap(); while (inputMap != null) { inputMap.clear(); inputMap = inputMap.getParent(); } // re-add select default input mappings textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "insert-break"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "insert-tab"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete-previous"); int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, keyMask), "delete-previous-word"); // add new input mappings textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, keyMask), "increase-font-size"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, keyMask), "decrease-font-size"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_S, keyMask), "save"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "quit"); textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, keyMask), "quit"); Action increaseFontSizeAction = new IncreaseFontSizeAction(); Action decreaseFontSizeAction = new DecreaseFontSizeAction(); Action saveAction = new SaveAction(); Action quitAction = new QuitAction(); textArea.getActionMap().put("increase-font-size", increaseFontSizeAction); textArea.getActionMap().put("decrease-font-size", decreaseFontSizeAction); textArea.getActionMap().put("save", saveAction); textArea.getActionMap().put("quit", quitAction); placeholder = Box.createGlue(); }
From source file:org.rimudb.editor.RimuDBEditor.java
public JMenuBar buildJMenuBar() { log.debug("buildJMenuBar()"); JMenuBar menuBar = new JMenuBar(); // File menu//w w w . j a v a2 s.c om JMenu menu = new JMenu("File"); menu.setMnemonic(KeyEvent.VK_F); openMenuItem = new JMenuItem( new OpenDescriptorAction(this, "Open...", loadIcon("/images/famfamfam/folder.png"))); openMenuItem.setName("OpenMenuItem"); openMenuItem.setMnemonic(KeyEvent.VK_O); openMenuItem.setAccelerator( KeyStroke.getKeyStroke('O', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); menu.add(openMenuItem); saveMenuItem = new JMenuItem( new SaveDescriptorAction(this, "Save", loadIcon("/images/famfamfam/disk.png"))); saveMenuItem.setName("SaveMenuItem"); saveMenuItem.setMnemonic(KeyEvent.VK_S); saveMenuItem.setAccelerator( KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); menu.add(saveMenuItem); saveAsMenuItem = new JMenuItem(new SaveAsDescriptorAction(this, "Save as...")); saveAsMenuItem.setName("SaveAsMenuItem"); menu.add(saveAsMenuItem); menu.addSeparator(); clearMenuItem = new JMenuItem( new ClearTableAction(this, "Clear...", loadIcon("/images/famfamfam/bin_closed.png"))); clearMenuItem.setName("ClearMenuItem"); clearMenuItem.setMnemonic(KeyEvent.VK_C); menu.add(clearMenuItem); preferencesMenuItem = new JMenuItem( new PreferencesAction(this, "Preferences...", loadIcon("/images/famfamfam/text_list_bullets.png"))); preferencesMenuItem.setName("PreferencesMenuItem"); preferencesMenuItem.setEnabled(false); preferencesMenuItem.setMnemonic(KeyEvent.VK_P); menu.add(preferencesMenuItem); menu.addSeparator(); exitMenuItem = new JMenuItem(new ExitAction(this, "Exit")); exitMenuItem.setName("ExitMenuItem"); exitMenuItem.setMnemonic(KeyEvent.VK_E); menu.add(exitMenuItem); menuBar.add(menu); JMenu toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic(KeyEvent.VK_T); dbImportMenuItem = new JMenuItem( new ImportAction(this, "Import from database...", loadIcon("/images/famfamfam/database_go.png"))); dbImportMenuItem.setName("DbImportMenuItem"); dbImportMenuItem.setEnabled(false); dbImportMenuItem.setMnemonic(KeyEvent.VK_I); dbImportMenuItem.setAccelerator( KeyStroke.getKeyStroke('I', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); toolsMenu.add(dbImportMenuItem); createClassesMenuItem = new JMenuItem(new GenerateJavaAction(this, "Create classes...", loadIcon("/images/famfamfam/page_white_cup.png"))); createClassesMenuItem.setName("CreateClassesMenuItem"); createClassesMenuItem.setMnemonic(KeyEvent.VK_C); toolsMenu.add(createClassesMenuItem); ddsExportMenuItem = new JMenuItem("Export as DDS..."); ddsExportMenuItem.setName("DdsExportMenuItem"); ddsExportMenuItem.setMnemonic(KeyEvent.VK_D); ddsExportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { actionExportToDDS(); } }); toolsMenu.add(ddsExportMenuItem); sqlExportMenuItem = new JMenuItem("Export as SQL..."); sqlExportMenuItem.setIcon(loadIcon("/images/famfamfam/page_white_database.png")); sqlExportMenuItem.setName("SqlExportMenuItem"); sqlExportMenuItem.setMnemonic(KeyEvent.VK_Q); sqlExportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { actionExportToSQL(); } }); toolsMenu.add(sqlExportMenuItem); toolsMenu.addSeparator(); propertyRenameMenuItem = new JMenuItem("Rename Properties..."); propertyRenameMenuItem.setName("PropertyRenameMenuItem"); propertyRenameMenuItem.setMnemonic(KeyEvent.VK_R); propertyRenameMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { actionRenameProperties(); } }); toolsMenu.add(propertyRenameMenuItem); copyCodeMenuItem = new JMenuItem(new GenerateCopyCodeAction(this, "Create Java DO Copy Code...", null)); copyCodeMenuItem.setName("CopyCodeMenuItem"); toolsMenu.add(copyCodeMenuItem); convertFinderMenuItem = new JMenuItem(new ConvertFinderAction(this, "Convert Finders (pre 1.1)...", null)); convertFinderMenuItem.setName("ConvertFinderMenuItem"); toolsMenu.add(convertFinderMenuItem); convertCDBMenuItem = new JMenuItem(new ConvertCDBAction(this, "Convert CDB Configs (pre 1.2)...", null)); convertCDBMenuItem.setName("ConvertCDBMenuItem"); toolsMenu.add(convertCDBMenuItem); menuBar.add(toolsMenu); JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic(KeyEvent.VK_H); aboutMenuItem = new JMenuItem(new AboutAction(this, "About...")); aboutMenuItem.setName("AboutMenuItem"); helpMenu.add(aboutMenuItem); menuBar.add(helpMenu); return menuBar; }
From source file:it.unibo.alchemist.boundary.monitors.Generic2DDisplay.java
private void bindKeys() { bindKey(KeyEvent.VK_S, () -> { if (status == ViewStatus.SELECTING) { resetStatus();/*from w w w .j a v a2 s . c o m*/ this.selectedNodes.clear(); } else if (!isInteracting()) { this.status = ViewStatus.SELECTING; } this.repaint(); }); bindKey(KeyEvent.VK_O, () -> { if (status == ViewStatus.SELECTING) { this.status = ViewStatus.MOVING; } }); bindKey(KeyEvent.VK_C, () -> { if (status == ViewStatus.SELECTING) { this.status = ViewStatus.CLONING; } }); bindKey(KeyEvent.VK_E, () -> { if (status == ViewStatus.SELECTING) { this.status = ViewStatus.MOLECULING; final JFrame mol = Generic2DDisplay.makeFrame("Moleculing", new MoleculeInjectorGUI<>(selectedNodes)); mol.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); mol.addWindowListener(new WindowAdapter() { @Override public void windowClosed(final WindowEvent e) { selectedNodes.clear(); resetStatus(); } }); } }); bindKey(KeyEvent.VK_D, () -> { if (status == ViewStatus.SELECTING) { this.status = ViewStatus.DELETING; for (final Node<T> n : selectedNodes) { currentEnv.removeNode(n); } final Simulation<T> sim = currentEnv.getSimulation(); sim.schedule(() -> update(currentEnv, sim.getTime())); resetStatus(); } }); bindKey(KeyEvent.VK_M, () -> setMarkCloserNode(!isCloserNodeMarked())); bindKey(KeyEvent.VK_L, () -> setDrawLinks(!paintLinks)); bindKey(KeyEvent.VK_P, () -> Optional.ofNullable(currentEnv.getSimulation()).ifPresent(sim -> { if (sim.getStatus() == Status.RUNNING) { sim.pause(); } else { sim.play(); } })); bindKey(KeyEvent.VK_R, () -> setRealTime(!isRealTime())); bindKey(KeyEvent.VK_LEFT, () -> setStep(Math.max(1, st - Math.max(st / 10, 1)))); bindKey(KeyEvent.VK_RIGHT, () -> setStep(Math.max(st, st + Math.max(st / 10, 1)))); }
From source file:sc.fiji.kappa.gui.KappaMenuBar.java
/** * Creates a menu-bar and adds menu items to it *///from w w w . j a va 2s . c o 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:terminotpad.MainFrame.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.// w w w . ja va 2 s. com */ @SuppressWarnings({ "unchecked", "Convert2Lambda" }) // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPopup_complete = new javax.swing.JPopupMenu(); jButton_stop = new javax.swing.JButton(); jButton_rollback = new javax.swing.JButton(); jButton_execute = new javax.swing.JButton(); jButton_commit = new javax.swing.JButton(); jTextPane_resultset = new javax.swing.JTextPane(); jLabel_searchbar = new javax.swing.JLabel(); jTextField_searchbar = new javax.swing.JTextField(); jFileChooser2 = new javax.swing.JFileChooser(); jScrollPane1 = new javax.swing.JScrollPane(); rSyntax = new org.fife.ui.rsyntaxtextarea.RSyntaxTextArea(); jMenuBar1 = new javax.swing.JMenuBar(); jMenuFile = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); jMenuItemQuit = new javax.swing.JMenuItem(); jMenuEdit = new javax.swing.JMenu(); jMenuItemOptions = new javax.swing.JMenuItem(); jMenuLang = new javax.swing.JMenu(); langSQL = new javax.swing.JMenuItem(); langJAVA = new javax.swing.JMenuItem(); langPHP = new javax.swing.JMenuItem(); langHTML = new javax.swing.JMenuItem(); langCSS = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("TermiNot'Pad - BETA"); setMinimumSize(new java.awt.Dimension(710, 500)); addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { formKeyPressed(evt); } }); jButton_stop.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/stop.png"))); // NOI18N jButton_stop.setText("Arrter"); jButton_stop.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_stopActionPerformed(evt); } }); jButton_rollback.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/cancel.png"))); // NOI18N jButton_rollback.setText("Rollback"); jButton_rollback.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_rollbackActionPerformed(evt); } }); jButton_execute.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/play.png"))); // NOI18N jButton_execute.setMnemonic(KeyEvent.VK_F1); jButton_execute.setText("Excuter"); jButton_execute.setToolTipText(""); jButton_execute.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_executeActionPerformed(evt); } }); jButton_commit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/valid.png"))); // NOI18N jButton_commit.setText("Commit"); jButton_commit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_commitActionPerformed(evt); } }); jLabel_searchbar.setText("Rechercher"); jTextField_searchbar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField_searchbarActionPerformed(evt); } }); jTextField_searchbar.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { jTextField_searchbarPropertyChange(evt); } }); jTextField_searchbar.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jTextField_searchbarKeyPressed(evt); } }); jFileChooser2.setControlButtonsAreShown(false); jFileChooser2.setCurrentDirectory(new java.io.File("F:\\Projets Java\\sql")); jFileChooser2.setName(""); // NOI18N jFileChooser2.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jFileChooser2MouseClicked(evt); } }); jFileChooser2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jFileChooser2ActionPerformed(evt); } }); rSyntax.setColumns(20); rSyntax.setRows(5); rSyntax.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { rSyntaxKeyReleased(evt); } }); jScrollPane1.setViewportView(rSyntax); jMenuFile.setText("Fichier"); jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem1.setText("Enregistrer"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenuFile.add(jMenuItem1); jMenuItemQuit.setText("Quitter"); jMenuItemQuit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemQuitActionPerformed(evt); } }); jMenuFile.add(jMenuItemQuit); jMenuBar1.add(jMenuFile); jMenuEdit.setText("Edition"); jMenuItemOptions.setText("Options"); jMenuItemOptions.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemOptionsActionPerformed(evt); } }); jMenuEdit.add(jMenuItemOptions); jMenuBar1.add(jMenuEdit); jMenuLang.setText("Langage"); langSQL.setText("SQL"); langSQL.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { langSQLActionPerformed(evt); } }); jMenuLang.add(langSQL); langJAVA.setText("JAVA"); langJAVA.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { langJAVAActionPerformed(evt); } }); jMenuLang.add(langJAVA); langPHP.setText("PHP"); langPHP.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { langPHPActionPerformed(evt); } }); jMenuLang.add(langPHP); langHTML.setText("HTML"); langHTML.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { langHTMLActionPerformed(evt); } }); jMenuLang.add(langHTML); langCSS.setText("CSS"); langCSS.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { langCSSActionPerformed(evt); } }); jMenuLang.add(langCSS); jMenuBar1.add(jMenuLang); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addComponent(jLabel_searchbar).addGap(18, 18, 18) .addComponent(jTextField_searchbar, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jFileChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, 370, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton_execute).addGap(18, 18, 18).addComponent(jButton_stop) .addGap(18, 18, 18).addComponent(jButton_rollback).addGap(18, 18, 18) .addComponent(jButton_commit).addContainerGap()) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1)))) .addComponent(jTextPane_resultset)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton_commit).addComponent(jButton_rollback) .addComponent(jButton_stop).addComponent(jButton_execute, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel_searchbar).addComponent(jTextField_searchbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jFileChooser2, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE) .addComponent(jScrollPane1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jTextPane_resultset, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); pack(); }
From source file:modnlp.capte.AlignmentInterfaceWS.java
public AlignmentInterfaceWS() { //Setup file chooser super(new BorderLayout()); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); this.setSize(dim.width, dim.height); //Create the log first, because the action listeners //need to refer to it. log = new JTextArea(5, 20); log.setMargin(new Insets(5, 5, 5, 5)); log.setEditable(false);//from w w w. j a v a 2s. c o m JScrollPane logScrollPane = new JScrollPane(log); //Create a file chooser fc = new JFileChooser(); //Uncomment one of the following lines to try a different //file selection mode. The first allows just directories //to be selected (and, at least in the Java look and feel, //shown). The second allows both files and directories //to be selected. If you leave these lines commented out, //then the default mode (FILES_ONLY) will be used. // //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); //fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); //Create the open button. We use the image from the JLF //Graphics Repository (but we extracted it from the jar). alignButton = new JButton("Align Texts"); alignButton.addActionListener(this); openButton = new JButton("Open Source File..."); openButton.addActionListener(this); //Create the save button. We use the image from the JLF //Graphics Repository (but we extracted it from the jar). saveButton = new JButton("Open Target File..."); saveButton.addActionListener(this); //Create two JText fields for input source and target language codes sl = new JTextField("en"); sourcel = sl.getText(); sol = new JLabel("Source"); tl = new JTextField("es"); targetl = tl.getText(); tol = new JLabel("Target"); splitButton = new JCheckBox("Splitter"); splitButton.setMnemonic(KeyEvent.VK_C); splitButton.setSelected(true); splitButton.addItemListener(this); convLine = new JCheckBox("Convert EOL"); convLine.setMnemonic(KeyEvent.VK_S); convLine.setSelected(true); convLine.addItemListener(this); sl.addActionListener(this); tl.addActionListener(this); //For layout purposes, put the buttons in a separate panel JPanel buttonPanel = new JPanel(); //use FlowLayout buttonPanel.add(openButton); buttonPanel.add(saveButton); //Make another panel for the aligner button JPanel alignPanel = new JPanel(); alignPanel.add(convLine); alignPanel.add(splitButton); alignPanel.add(sol); alignPanel.add(sl); alignPanel.add(tol); alignPanel.add(tl); alignPanel.add(alignButton); //Add the buttons and the log to this panel. add(buttonPanel, BorderLayout.PAGE_START); add(logScrollPane, BorderLayout.CENTER); add(alignPanel, BorderLayout.PAGE_END); }
From source file:ffx.ui.MainMenu.java
/** * <p>//w ww.j ava 2 s . c om * Constructor for MainMenu.</p> * * @param f a {@link ffx.ui.MainPanel} object. */ public MainMenu(MainPanel f) { // Create the Tool Bar toolBar = new JToolBar("Toolbar", JToolBar.HORIZONTAL); toolBar.setBorderPainted(true); toolBar.setRollover(true); JButton temp = new JButton(); insets = temp.getInsets(); insets.set(2, 2, 2, 2); mainPanel = f; graphics = mainPanel.getGraphics3D(); locale = mainPanel.getFFXLocale(); loader = getClass().getClassLoader(); blankIcon = new ImageIcon(loader.getResource(icons + "blank.gif")); String value = System.getProperty("structures", "false").trim(); try { includeStructureMenu = Boolean.parseBoolean(value); } catch (Exception e) { includeStructureMenu = false; } /** * Main Menubar */ JMenu fileMenu = addMenu("File", 'F'); JMenu selectionMenu = addMenu("Selection", 'E'); JMenu structureMenu = null; if (includeStructureMenu) { structureMenu = addMenu("Structure", 'S'); } JMenu displayMenu = addMenu("Display", 'D'); JMenu colorMenu = addMenu("Color", 'C'); JMenu optionsMenu = addMenu("Options", 'O'); JMenu pickingMenu = addMenu("Picking", 'P'); JMenu trajectoryMenu = addMenu("Trajectory", 'T'); JMenu exportMenu = addMenu("Export", 'X'); JMenu windowMenu = addMenu("Window", 'W'); JMenu helpMenu = addMenu("Help", 'H'); /** * File Menu - Events Handled by the MainPanel Class. */ addMenuItem(fileMenu, icons + "folder_page", "Open", 'O', KeyEvent.VK_O, mainPanel); addMenuItem(fileMenu, icons + "disk", "SaveAs", 'S', KeyEvent.VK_S, mainPanel); addMenuItem(fileMenu, icons + "cancel", "Close", 'C', -1, mainPanel); addMenuItem(fileMenu, "BLANK", "CloseAll", 'A', -1, mainPanel); fileMenu.addSeparator(); addMenuItem(fileMenu, icons + "drive_web", "DownloadFromPDB", 'D', KeyEvent.VK_D, mainPanel); fileMenu.addSeparator(); addMenuItem(fileMenu, "BLANK", "ChooseKeyFile", 'R', -1, mainPanel); addMenuItem(fileMenu, "BLANK", "ChooseLogFile", 'I', -1, mainPanel); addMenuItem(fileMenu, "BLANK", "LoadRestartData", 'R', -1, mainPanel); if (!SystemUtils.IS_OS_MAC_OSX) { fileMenu.addSeparator(); addMenuItem(fileMenu, "BLANK", "Exit", 'E', KeyEvent.VK_Q, mainPanel); } toolBar.addSeparator(); /** * Selection Menu - Events Handled by the MainPanel and GraphicsCanvas. */ addMenuItem(selectionMenu, icons + "add", "SelectAll", 'A', KeyEvent.VK_A, mainPanel); addMenuItem(selectionMenu, "BLANK", "RestrictToSelections", 'R', -1, graphics); addMenuItem(selectionMenu, icons + "arrow_merge", "MergeSelections", 'M', -1, mainPanel); selectionMenu.addSeparator(); highlightCBMI = addCBMenuItem(selectionMenu, icons + "asterisk_yellow", "HighlightSelections", 'H', KeyEvent.VK_H, mainPanel); addMenuItem(selectionMenu, "BLANK", "SetSelectionColor", 'S', -1, graphics); selectionMenu.addSeparator(); labelAtomsMI = addCBMenuItem(selectionMenu, "BLANK", "LabelSelectedAtoms", 'O', -1, graphics); labelResiduesMI = addCBMenuItem(selectionMenu, "BLANK", "LabelSelectedResidues", 'R', -1, graphics); addMenuItem(selectionMenu, "BLANK", "SetLabelFontSize", 'Z', -1, graphics); addMenuItem(selectionMenu, "BLANK", "SetLabelFontColor", 'C', -1, graphics); highlightCBMI.setSelected(false); labelAtomsMI.setSelected(false); labelResiduesMI.setSelected(false); toolBar.addSeparator(); /** * Structure Menu - Events Handled by the MainPanel. */ if (includeStructureMenu) { // Locate a jar file that has PDB Structures. String file = "ffx/xray/structures/1N7S.pdb"; addMenuItem(structureMenu, "BLANK", file, '.', -1, mainPanel); } /** * Display Menu - Events handled by the GraphicsCanvas. */ addMenuItem(displayMenu, "BLANK", "Wireframe", 'W', -1, graphics); addMenuItem(displayMenu, "BLANK", "Tube", 'T', -1, graphics); addMenuItem(displayMenu, "BLANK", "Spacefill", 'S', -1, graphics); addMenuItem(displayMenu, "BLANK", "BallAndStick", 'B', -1, graphics); addMenuItem(displayMenu, "BLANK", "Invisible", 'I', -1, graphics); addMenuItem(displayMenu, "BLANK", "RMIN", 'R', -1, graphics); displayMenu.addSeparator(); addMenuItem(displayMenu, "BLANK", "ShowHydrogens", 'H', -1, graphics); addMenuItem(displayMenu, "BLANK", "HideHydrogens", 'Y', -1, graphics); displayMenu.addSeparator(); addMenuItem(displayMenu, "BLANK", "Fill", 'F', -1, graphics); addMenuItem(displayMenu, "BLANK", "Points", 'P', -1, graphics); addMenuItem(displayMenu, "BLANK", "Lines", 'I', -1, graphics); displayMenu.addSeparator(); addMenuItem(displayMenu, "BLANK", "Preferences", 'P', -1, graphics); /** * Color Menu - Events handled by the GraphicsCanvas. */ addMenuItem(colorMenu, "BLANK", "Monochrome", 'M', -1, graphics); addMenuItem(colorMenu, "BLANK", "CPK", 'C', -1, graphics); addMenuItem(colorMenu, "BLANK", "Residue", 'R', -1, graphics); addMenuItem(colorMenu, "BLANK", "Structure", 'S', -1, graphics); addMenuItem(colorMenu, "BLANK", "Polymer", 'M', -1, graphics); addMenuItem(colorMenu, "BLANK", "PartialCharge", 'P', -1, graphics); addMenuItem(colorMenu, "BLANK", "UserColor", 'U', -1, graphics); colorMenu.addSeparator(); addMenuItem(colorMenu, "BLANK", "ApplyUserColor", 'A', -1, graphics); addMenuItem(colorMenu, "BLANK", "SetUserColor", 'C', -1, graphics); /** * Options Menu - Events handled by the GraphicsCanvas. */ dragModeButtonGroup = new ButtonGroup(); activeRBMI = addBGMI(dragModeButtonGroup, optionsMenu, "BLANK", "ActiveSystem", 'A', KeyEvent.VK_A, graphics); mouseRBMI = addBGMI(dragModeButtonGroup, optionsMenu, "BLANK", "SystemBelowMouse", 'S', KeyEvent.VK_M, graphics); activeRBMI.setSelected(true); optionsMenu.addSeparator(); JMenu leftMouseMenu = addSubMenu(optionsMenu, "LeftMouseButton", 'M'); leftMouseButtonGroup = new ButtonGroup(); rotateRBMI = addBGMI(leftMouseButtonGroup, leftMouseMenu, "BLANK", "Rotate", 'R', KeyEvent.VK_R, graphics); addBGMI(leftMouseButtonGroup, leftMouseMenu, "BLANK", "Translate", 'T', KeyEvent.VK_T, graphics); addBGMI(leftMouseButtonGroup, leftMouseMenu, "BLANK", "Zoom", 'Z', KeyEvent.VK_Z, graphics); rotateRBMI.setSelected(true); optionsMenu.addSeparator(); addMenuItem(optionsMenu, "BLANK", "RotateAboutCenter", 'C', KeyEvent.VK_C, graphics); addMenuItem(optionsMenu, "BLANK", "RotateAboutPick", 'P', KeyEvent.VK_P, graphics); addMenuItem(optionsMenu, "BLANK", "ResetRotation", 'R', -1, graphics); addMenuItem(optionsMenu, "BLANK", "ResetTranslation", 'T', -1, graphics); addMenuItem(optionsMenu, icons + "arrow_refresh", "ResetRotationAndTranslation", 'E', -1, graphics); optionsMenu.addSeparator(); addMenuItem(optionsMenu, icons + "magnifier_zoom_in", "ZoomIn", 'I', -1, graphics); addMenuItem(optionsMenu, icons + "magnifier_zoom_out", "ZoomOut", 'O', -1, graphics); addMenuItem(optionsMenu, "BLANK", "ResetGlobalZoom", 'Z', -1, graphics); addMenuItem(optionsMenu, "BLANK", "ResetGlobalRotation", 'N', -1, graphics); addMenuItem(optionsMenu, "BLANK", "ResetGlobalTranslation", 'O', -1, graphics); addMenuItem(optionsMenu, icons + "house", "ResetGlobalView", 'V', -1, graphics); optionsMenu.addSeparator(); addMenuItem(optionsMenu, "BLANK", "SetBackgroundColor", 'B', -1, graphics); toolBar.addSeparator(); /** * Picking Menu - Events handled by the GraphicsCanvas. */ levelBG = new ButtonGroup(); pickingCBMI = addCBMenuItem(pickingMenu, icons + "wand", "GraphicsPicking", 'G', KeyEvent.VK_0, graphics); pickingCBMI.setSelected(false); pickingMenu.addSeparator(); atomRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickAtom", 'A', KeyEvent.VK_1, graphics); bondRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickBond", 'B', KeyEvent.VK_2, graphics); angleRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickAngle", 'N', KeyEvent.VK_3, graphics); dihedralRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickDihedral", 'D', KeyEvent.VK_4, graphics); residueRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickResidue", 'R', KeyEvent.VK_5, graphics); polymerRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickPolymer", 'P', KeyEvent.VK_6, graphics); moleculeRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickMolecule", 'M', KeyEvent.VK_7, graphics); systemRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickSystem", 'S', KeyEvent.VK_8, graphics); pickingMenu.addSeparator(); measureDistanceRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "MeasureDistance", 'I', -1, graphics); measureAngleRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "MeasureAngle", 'L', -1, graphics); measureDihedralRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "MeasureDihedral", 'H', -1, graphics); atomRBMI.setSelected(true); pickingMenu.addSeparator(); addMenuItem(pickingMenu, "BLANK", "SetGraphicsPickingColor", 'S', -1, graphics); toolBar.addSeparator(); /** * Trajectory Menu - Events handled by the MainPanel. */ oscillateCBMI = addCBMenuItem(trajectoryMenu, icons + "control_repeat_blue", "Oscillate", 'O', -1, mainPanel); oscillateCBMI.setSelected(false); addMenuItem(trajectoryMenu, "BLANK", "Frame", 'A', -1, mainPanel); addMenuItem(trajectoryMenu, "BLANK", "Speed", 'E', -1, mainPanel); addMenuItem(trajectoryMenu, "BLANK", "Skip", 'K', -1, mainPanel); trajectoryMenu.addSeparator(); addMenuItem(trajectoryMenu, icons + "control_play_blue", "Play", 'P', -1, mainPanel); addMenuItem(trajectoryMenu, icons + "control_stop_blue", "Stop", 'S', -1, mainPanel); addMenuItem(trajectoryMenu, icons + "control_fastforward_blue", "StepForward", 'F', -1, mainPanel); addMenuItem(trajectoryMenu, icons + "control_rewind_blue", "StepBack", 'B', -1, mainPanel); addMenuItem(trajectoryMenu, icons + "control_start_blue", "Reset", 'R', -1, mainPanel); toolBar.addSeparator(); /** * Export Menu - Events handled by the GraphicsCanvas. */ addMenuItem(exportMenu, icons + "camera", "CaptureGraphics", 'C', KeyEvent.VK_G, graphics); exportMenu.addSeparator(); captureFormatButtonGroup = new ButtonGroup(); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "PNG", 'P', -1, graphics).setSelected(true); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "JPEG", 'J', -1, graphics); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "BMP", 'B', -1, graphics); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "WBMP", 'W', -1, graphics); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "GIF", 'G', -1, graphics); toolBar.addSeparator(); /** * Window Menu - Events handled by the GraphicsCanvas. */ addMenuItem(windowMenu, icons + "application_home", "ResetPanes", 'R', -1, mainPanel); addMenuItem(windowMenu, icons + "application_osx_terminal", "ResetConsole", 'L', -1, mainPanel); windowMenu.addSeparator(); addMenuItem(windowMenu, icons + "application_side_contract", "ExpandGraphicsWindow", 'E', -1, mainPanel); addMenuItem(windowMenu, icons + "application_side_expand", "ShrinkGraphicsWindow", 'L', -1, mainPanel); windowMenu.addSeparator(); systemsCBMI = addCBMenuItem(windowMenu, "BLANK", "ShowTree", 'T', -1, mainPanel); toolBarCBMI = addCBMenuItem(windowMenu, "BLANK", "ShowToolBar", 'B', -1, mainPanel); globalAxisCBMI = addCBMenuItem(windowMenu, "BLANK", "ShowGlobalAxes", 'C', -1, mainPanel); globalAxisCBMI.setSelected(true); toolBar.addSeparator(); /** * Help Menu - Events handled by the MainPanel. */ Action a = addMenuItem(helpMenu, icons + "help", "HelpContents", 'H', KeyEvent.VK_HELP, mainPanel); /** * Fix the ACCELERATOR_KEY for the Help menu item; no modifiers will be * used. */ a.putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0)); addMenuItem(helpMenu, "BLANK", "About", 'A', -1, mainPanel); }