List of usage examples for javax.swing KeyStroke getKeyStroke
public static KeyStroke getKeyStroke(int keyCode, int modifiers)
From source file:com.net2plan.gui.tools.GUINetworkDesign.java
@Override public KeyStroke getKeyStroke() { return KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.ALT_DOWN_MASK); }
From source file:com.isencia.passerelle.hmi.HMIBase.java
/** * Constructs a default menu./*from www . ja va2 s . com*/ * <ul> * <li>If the menuItems set is null, all default items are created. * <li>If the set is not null, only the menu items whose names are in there * are shown * </ul> * For an overview of the names, check HMIMessages.MENU_... * * @param menuItemsToShow * @param menuItemsToHide * @return */ public JMenuBar createDefaultMenu(final Set<String> menuItemsToShow, final Set<String> menuItemsToHide) { final JMenuBar menuBar = new JMenuBar(); final JMenu fileMenu = new JMenu(HMIMessages.getString(HMIMessages.MENU_FILE)); fileMenu.setMnemonic(HMIMessages.getString(HMIMessages.MENU_FILE + HMIMessages.KEY).charAt(0)); if (showThing(HMIMessages.MENU_TEMPLATES, menuItemsToShow, menuItemsToHide)) { final JMenu templatesSubMenu = new JMenu(HMIMessages.getString(HMIMessages.MENU_TEMPLATES)); final Iterator itr = hmiModelsDef.getModels().keySet().iterator(); final List<String> orderedList = new ArrayList<String>(); while (itr.hasNext()) { final String modelKey = (String) itr.next(); final String labelKey = modelKey; // HMIMessages.getString(modelKey); orderedList.add(labelKey); } Collections.sort(orderedList); for (int i = 0; i < orderedList.size(); i++) { try { // JMenuItem templateMenuItem = new // JMenuItem(HMIMessages.getString(HMIMessages.MENU_TEMPLATES) // + " " + HMIMessages.getString(modelKey)); final JMenuItem templateMenuItem = new JMenuItem(HMIMessages.getString(orderedList.get(i))); templateMenuItem.addActionListener(new TemplateModelOpener(orderedList.get(i))); templatesSubMenu.add(templateMenuItem); } catch (final Exception e1) { e1.printStackTrace(); logger.error("", e1); } } fileMenu.add(templatesSubMenu); StateMachine.getInstance().registerActionForState(StateMachine.READY, HMIMessages.MENU_TEMPLATES, templatesSubMenu); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_TEMPLATES, templatesSubMenu); } if (showModelGraph) { if (showThing(HMIMessages.MENU_NEW, menuItemsToShow, menuItemsToHide)) { if (modelCreatorAction == null) { modelCreatorAction = new ModelCreator(this); } fileMenu.add(modelCreatorAction); // final JMenuItem fileNewMenuItem = new JMenuItem(HMIMessages // .getString(HMIMessages.MENU_NEW), HMIMessages.getString( // HMIMessages.MENU_NEW + HMIMessages.KEY).charAt(0)); // fileNewMenuItem.setAccelerator(KeyStroke.getKeyStroke( // KeyEvent.VK_N, InputEvent.CTRL_MASK)); // fileNewMenuItem.addActionListener(new ModelCreator()); // fileMenu.add(fileNewMenuItem); // StateMachine.getInstance().registerActionForState( // StateMachine.READY, HMIMessages.MENU_NEW, fileNewMenuItem); // StateMachine.getInstance().registerActionForState( // StateMachine.MODEL_OPEN, HMIMessages.MENU_NEW, // fileNewMenuItem); } } if (showThing(HMIMessages.MENU_OPEN, menuItemsToShow, menuItemsToHide)) { final JMenuItem fileOpenMenuItem = new JMenuItem(HMIMessages.getString(HMIMessages.MENU_OPEN), HMIMessages.getString(HMIMessages.MENU_OPEN + HMIMessages.KEY).charAt(0)); fileOpenMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); fileOpenMenuItem.addActionListener(new ModelOpener()); fileMenu.add(fileOpenMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.READY, HMIMessages.MENU_OPEN, fileOpenMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_OPEN, fileOpenMenuItem); } if (showThing(HMIMessages.MENU_CLOSE, menuItemsToShow, menuItemsToHide)) { final JMenuItem fileCloseMenuItem = new JMenuItem(HMIMessages.getString(HMIMessages.MENU_CLOSE), HMIMessages.getString(HMIMessages.MENU_CLOSE + HMIMessages.KEY).charAt(0)); fileCloseMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK)); fileCloseMenuItem.addActionListener(new ModelCloser()); fileMenu.add(fileCloseMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_CLOSE, fileCloseMenuItem); } if (showThing(HMIMessages.MENU_SAVE, menuItemsToShow, menuItemsToHide)) { fileMenu.add(new JSeparator()); if (saveAction == null) { saveAction = new SaveAction(this); } fileMenu.add(saveAction); // StateMachine.getInstance().registerActionForState( // StateMachine.MODEL_OPEN, HMIMessages.MENU_SAVE, save); } if (showThing(HMIMessages.MENU_SAVEAS, menuItemsToShow, menuItemsToHide)) { if (saveAsAction == null) { saveAsAction = new SaveAsAction(this); } fileMenu.add(saveAsAction); // StateMachine.getInstance().registerActionForState( // StateMachine.MODEL_OPEN, HMIMessages.MENU_SAVEAS, save); } if (showThing(HMIMessages.MENU_EXIT, menuItemsToShow, menuItemsToHide)) { final JMenuItem exitMenuItem = new JMenuItem(HMIMessages.getString(HMIMessages.MENU_EXIT), HMIMessages.getString(HMIMessages.MENU_EXIT + HMIMessages.KEY).charAt(0)); exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { if (logger.isTraceEnabled()) { logger.trace("Exit action - entry"); //$NON-NLS-1$ } logger.info(HMIMessages.getString(HMIMessages.INFO_EXIT)); // DBA to be validating... // Application which use HMIBase needs to call exit // treatment before exiting exitApplication(); if (logger.isTraceEnabled()) { logger.trace("Exit action - exit"); //$NON-NLS-1$ } System.exit(0); } }); fileMenu.add(new JSeparator()); fileMenu.add(exitMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.READY, HMIMessages.MENU_EXIT, exitMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_EXIT, exitMenuItem); } final JMenu runMenu = new JMenu(HMIMessages.getString(HMIMessages.MENU_RUN)); runMenu.setMnemonic(HMIMessages.getString(HMIMessages.MENU_RUN + HMIMessages.KEY).charAt(0)); if (showThing(HMIMessages.MENU_EXECUTE, menuItemsToShow, menuItemsToHide)) { if (modelExecutor == null) { modelExecutor = new ModelExecutor(this); } final JMenuItem runExecuteMenuItem = new JMenuItem(modelExecutor); runMenu.add(runExecuteMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_EXECUTE, modelExecutor); } if (showThing(HMIMessages.MENU_STOP, menuItemsToShow, menuItemsToHide)) { if (modelStopper == null) { modelStopper = new ModelStopper(this); } final JMenuItem stopExecuteMenuItem = new JMenuItem(modelStopper); runMenu.add(stopExecuteMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_EXECUTING, HMIMessages.MENU_STOP, modelStopper); } if (showThing(HMIMessages.MENU_INTERACTIVE_ERRORHANDLING, menuItemsToShow, menuItemsToHide)) { final JMenuItem interactiveErrorCtrlMenuItem = new JCheckBoxMenuItem( HMIMessages.getString(HMIMessages.MENU_INTERACTIVE_ERRORHANDLING)); interactiveErrorCtrlMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { interactiveErrorControl = ((JCheckBoxMenuItem) e.getSource()).getState(); } }); runMenu.add(new JSeparator()); runMenu.add(interactiveErrorCtrlMenuItem); } final JMenu graphMenu = new JMenu(HMIMessages.getString(HMIMessages.MENU_GRAPH)); graphMenu.setMnemonic(HMIMessages.getString(HMIMessages.MENU_GRAPH + HMIMessages.KEY).charAt(0)); // if (showThing(HMIMessages.MENU_SHOW, menuItemsToShow, // menuItemsToHide)) { // JMenuItem graphViewMenuItem = new // JCheckBoxMenuItem(HMIMessages.getString(HMIMessages.MENU_SHOW)); // graphMenu.add(graphViewMenuItem); // // graphViewMenuItem.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // if (logger.isTraceEnabled()) { // logger.trace("Graph Show action - entry"); //$NON-NLS-1$ // } // boolean showGraph = ((JCheckBoxMenuItem) e.getSource()).getState(); // if(showGraph) { // applyFieldValuesToParameters(); // clearModelForms(); // showModelGraph(HMIBase.this.currentModel.getName()); // } else { // clearModelGraphs(); // showModelForm(HMIBase.this.currentModel.getName()); // } // if (logger.isTraceEnabled()) { // logger.trace("Graph Show action - exit"); //$NON-NLS-1$ // } // } // // // }); // } if (showThing(HMIMessages.MENU_ANIMATE, menuItemsToShow, menuItemsToHide)) { final JMenuItem animateGraphViewMenuItem = new JCheckBoxMenuItem( HMIMessages.getString(HMIMessages.MENU_ANIMATE)); animateGraphViewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { animateModelExecution = ((JCheckBoxMenuItem) e.getSource()).getState(); } }); graphMenu.add(new JSeparator()); graphMenu.add(animateGraphViewMenuItem); } if (fileMenu.getMenuComponentCount() > 0) { menuBar.add(fileMenu); } if (runMenu.getMenuComponentCount() > 0) { menuBar.add(runMenu); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_RUN, runMenu); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_EXECUTING, HMIMessages.MENU_RUN, runMenu); } if (graphMenu.getMenuComponentCount() > 0) { menuBar.add(graphMenu); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_GRAPH, graphMenu); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_EXECUTING, HMIMessages.MENU_GRAPH, graphMenu); } final JMenu monitoringMenu = new JMenu(HMIMessages.getString(HMIMessages.MENU_MONITORING)); monitoringMenu.setMnemonic(HMIMessages.getString(HMIMessages.MENU_MONITORING + HMIMessages.KEY).charAt(0)); if (showThing(HMIMessages.MENU_TRACING, menuItemsToShow, menuItemsToHide)) { final JMenuItem traceMenuItem = new JMenuItem(HMIMessages.getString(HMIMessages.MENU_TRACING), HMIMessages.getString(HMIMessages.MENU_TRACING + HMIMessages.KEY).charAt(0)); traceMenuItem.addActionListener(new TraceDialogOpener()); monitoringMenu.add(traceMenuItem); } if (monitoringMenu.getMenuComponentCount() > 0) { menuBar.add(monitoringMenu); } StateMachine.getInstance().compile(); StateMachine.getInstance().transitionTo(StateMachine.READY); return menuBar; }
From source file:fll.subjective.SubjectiveFrame.java
/** * Set the tab and return behavior for a table. */// w w w . j a v a2 s.c om private void setupTabReturnBehavior(final JTable table) { final InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); // Have the enter key work the same as the tab key final KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0); final KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); im.put(enter, im.get(tab)); // Override the default tab behavior // Tab to the next editable cell. When no editable cells goto next cell. final Action oldTabAction = table.getActionMap().get(im.get(tab)); final Action tabAction = new AbstractAction() { public void actionPerformed(final ActionEvent e) { if (null != oldTabAction) { oldTabAction.actionPerformed(e); } final JTable table = (JTable) e.getSource(); final int rowCount = table.getRowCount(); final int columnCount = table.getColumnCount(); int row = table.getSelectedRow(); int column = table.getSelectedColumn(); // skip the no show when tabbing while (!table.isCellEditable(row, column) || table.getColumnClass(column) == Boolean.class) { column += 1; if (column == columnCount) { column = 0; row += 1; } if (row == rowCount) { row = 0; } // Back to where we started, get out. if (row == table.getSelectedRow() && column == table.getSelectedColumn()) { break; } } table.changeSelection(row, column, false, false); } }; table.getActionMap().put(im.get(tab), tabAction); }
From source file:ffx.ui.MainMenu.java
/** * <p>//from w w w .j a v a 2 s . c o m * 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); }
From source file:com.intuit.tank.proxy.ProxyApp.java
@SuppressWarnings("serial") public JMenuBar createMenu() { JMenuBar ret = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenu sessionMenu = new JMenu("Session"); ret.add(fileMenu);/*from ww w .j av a2 s . c o m*/ ret.add(sessionMenu); fileMenu.add(getMenuItem(openAction)); fileMenu.add(getMenuItem(saveAction)); fileMenu.addSeparator(); fileMenu.add(getMenuItem(filterAction)); fileMenu.add(getMenuItem(settingsAction)); fileMenu.addSeparator(); AbstractAction quitAction = new AbstractAction("Quit") { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }; quitAction.putValue(javax.swing.Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Q, keyMask)); quitAction.putValue(javax.swing.Action.MNEMONIC_KEY, KeyEvent.VK_Q); fileMenu.add(new JMenuItem(quitAction)); sessionMenu.add(getMenuItem(startAction)); sessionMenu.add(getMenuItem(stopAction)); sessionMenu.add(getMenuItem(pauseAction)); sessionMenu.addSeparator(); sessionMenu.add(getMenuItem(showHostsAction)); return ret; }
From source file:forge.screens.match.CMatchUI.java
@Override public SpellAbility getAbilityToPlay(List<SpellAbility> abilities, ITriggerEvent triggerEvent) { if (triggerEvent == null) { if (abilities.isEmpty()) { return null; }//from w w w. jav a2s .c om if (abilities.size() == 1) { return abilities.get(0); } return GuiChoose.oneOrNone("Choose ability to play", abilities); } if (abilities.isEmpty()) { return null; } if (abilities.size() == 1 && !abilities.get(0).promptIfOnlyPossibleAbility()) { if (abilities.get(0).canPlay()) { return abilities.get(0); //only return ability if it's playable, otherwise return null } return null; } //show menu if mouse was trigger for ability final JPopupMenu menu = new JPopupMenu("Abilities"); boolean enabled; boolean hasEnabled = false; int shortcut = KeyEvent.VK_1; //use number keys as shortcuts for abilities 1-9 for (final SpellAbility ab : abilities) { enabled = ab.canPlay(); if (enabled) { hasEnabled = true; } GuiUtils.addMenuItem(menu, FSkin.encodeSymbols(ab.toString(), true), shortcut > 0 ? KeyStroke.getKeyStroke(shortcut, 0) : null, new Runnable() { @Override public void run() { CPrompt.SINGLETON_INSTANCE.selectAbility(ab); } }, enabled); if (shortcut > 0) { shortcut++; if (shortcut > KeyEvent.VK_9) { shortcut = 0; //stop adding shortcuts after 9 } } } if (hasEnabled) { //only show menu if at least one ability can be played SwingUtilities.invokeLater(new Runnable() { //use invoke later to ensure first ability selected by default public void run() { MenuSelectionManager.defaultManager() .setSelectedPath(new MenuElement[] { menu, menu.getSubElements()[0] }); } }); MouseEvent mouseEvent = ((MouseTriggerEvent) triggerEvent).getMouseEvent(); menu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); } return null; //delay ability until choice made }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.navegacao_cego.PainelSimuladorNavegacao.java
private JMenuBar criaMenuBar() { menuBar = new JMenuBar(); menuBar.setBackground(parentFrame.corDefault); JMenu menuArquivo = new JMenu(GERAL.ARQUIVO); menuArquivo.setMnemonic('A'); menuArquivo.setMnemonic(KeyEvent.VK_A); menuArquivo.setBackground(parentFrame.corDefault); JMenu avaliadores = new JMenu(); MenuSilvinha menuSilvinha = new MenuSilvinha(parentFrame, null); menuSilvinha.criaMenuAvaliadores(avaliadores); // menuArquivo.add(avaliadores); // menuArquivo.add(new JSeparator()); JMenuItem btnAbrir = new JMenuItem(GERAL.BTN_ABRIR); btnAbrir.addActionListener(this); btnAbrir.setActionCommand("Abrir"); btnAbrir.setMnemonic('A'); btnAbrir.setAccelerator(/*www . ja va2s .co m*/ javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, ActionEvent.CTRL_MASK)); btnAbrir.setMnemonic(KeyEvent.VK_A); btnAbrir.setToolTipText(TradSimuladorNavegacao.DICA_ABRE_E_AVALIA); btnAbrir.getAccessibleContext().setAccessibleDescription(TradSimuladorNavegacao.DICA_ABRE_E_AVALIA); menuArquivo.add(btnAbrir); JMenuItem btnAbrirUrl = new JMenuItem(XHTML_Panel.BTN_ABRIR_URL); btnAbrirUrl.addActionListener(this); btnAbrirUrl.setActionCommand("AbrirURL"); btnAbrirUrl.setMnemonic('U'); btnAbrirUrl.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, ActionEvent.CTRL_MASK)); btnAbrirUrl.setMnemonic(KeyEvent.VK_U); btnAbrirUrl.setToolTipText(XHTML_Panel.DICA_ABRIR); btnAbrirUrl.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_ABRIR); menuArquivo.add(btnAbrirUrl); btnSalvar = new JMenuItem(GERAL.BTN_SALVAR); btnSalvar.addActionListener(this); btnSalvar.setActionCommand("Salvar"); btnSalvar.setMnemonic('S'); btnSalvar.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, ActionEvent.CTRL_MASK)); btnSalvar.setMnemonic(KeyEvent.VK_S); btnSalvar.getAccessibleContext().setAccessibleDescription(TradSimuladorNavegacao.DICA_GRAVA_E_REAVALIA); // menuArquivo.add(btnSalvar); JMenuItem btnSalvarAs = new JMenuItem(GERAL.BTN_SALVAR_COMO); btnSalvarAs.addActionListener(this); btnSalvarAs.setActionCommand("SaveAs"); btnSalvarAs.setMnemonic('c'); btnSalvarAs.setMnemonic(KeyEvent.VK_C); // btnSalvarAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, // ActionEvent.CTRL_MASK)); btnSalvarAs.setToolTipText(GERAL.DICA_SALVAR_COMO); btnSalvarAs.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SALVAR_COMO); // menuArquivo.add(btnSalvarAs); menuArquivo.add(new JSeparator()); JMenuItem btnFechar = new JMenuItem(GERAL.SAIR); //btnFechar.addActionListener(this); btnFechar.setActionCommand("Sair"); //btnFechar.setMnemonic(KeyEvent.VK_X); btnFechar.setToolTipText(GERAL.DICA_SAIR); //btnFechar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SAIR); menuArquivo.add(btnFechar); btnFechar.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK)); btnFechar.setMnemonic('X'); btnFechar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); menuBar.add(menuArquivo); menuBar.add(this.criaMenuEditar()); menuBar.add(avaliadores); JMenu menuSimuladores = new JMenu(); menuSilvinha.criaMenuSimuladores(menuSimuladores); menuBar.add(menuSimuladores); JMenu mnFerramenta = new JMenu(); menuSilvinha.criaMenuFerramentas(mnFerramenta); menuBar.add(mnFerramenta); JMenu menuAjuda = new JMenu(GERAL.AJUDA); menuSilvinha.criaMenuAjuda(menuAjuda); menuBar.add(menuAjuda); return menuBar; }
From source file:com.kstenschke.copypastestack.ToolWindow.java
/** * Add undoManager to clip pane/*w ww . jav a2 s.co m*/ */ private void initInlineEditor() { Document document = this.form.textPanePreview.getDocument(); if (this.undoManager != null) { document.removeUndoableEditListener(this.undoManager); } this.undoManager = new UndoManager(); document.addUndoableEditListener(this.undoManager); final ToolWindow toolWindowFin = this; InputMap inputMap = this.form.textPanePreview.getInputMap(); // CTRL + Z = undo ( + Z on Mac OS) inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (toolWindowFin.undoManager.canUndo()) { toolWindowFin.undoManager.undo(); } } }); // CTRL + SHIFT + Z = redo ( + SHIFT + Z on Mac OS) inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.SHIFT_DOWN_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (toolWindowFin.undoManager.canRedo()) { toolWindowFin.undoManager.redo(); } } }); }
From source file:org.samjoey.gui.GraphicalViewer.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.//from www. j a v a 2 s . com */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel_Parser = new javax.swing.JPanel(); jTextField_Parser = new javax.swing.JTextField(); jButton_Parser_Open = new javax.swing.JButton(); parserProgress = new javax.swing.JProgressBar(); jPanel1 = new javax.swing.JPanel(); jButton_PreviousGame = new javax.swing.JButton(); jButton_Next_Game = new javax.swing.JButton(); jButton_Previous_Ply = new javax.swing.JButton(); jButton_Next_Ply = new javax.swing.JButton(); jScrollPane2 = new javax.swing.JScrollPane(); jTextArea_Game_Viewer = new javax.swing.JTextPane(); Ply_Label = new javax.swing.JLabel(); Game_Label = new javax.swing.JLabel(); Variable_Viewer_Panel = new javax.swing.JPanel(); jScrollPane3 = new javax.swing.JScrollPane(); jScrollPane1 = new javax.swing.JScrollPane(); Variable_Viewer_Textpane = new javax.swing.JTextPane(); Graph_Panel = new javax.swing.JPanel(); Variable_Chooser = new javax.swing.JComboBox(); graphFrame = new javax.swing.JInternalFrame(); jPanel2 = new javax.swing.JPanel(); pattern_Button = new javax.swing.JButton(); writerPanel = new javax.swing.JPanel(); pattern_Button1 = new javax.swing.JButton(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); jMenu_Open = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); jMenu_Game = new javax.swing.JMenuItem(); jMenu_Ply = new javax.swing.JMenuItem(); Graphs_MenuItem = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setPreferredSize(new java.awt.Dimension(20000, 20000)); jPanel_Parser.setBorder( javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Parser", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP)); jPanel_Parser.setName("Parser"); // NOI18N jTextField_Parser.setText("No File Chosen"); jTextField_Parser.setEnabled(false); jTextField_Parser.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField_ParserActionPerformed(evt); } }); jButton_Parser_Open.setText("Parse"); jButton_Parser_Open.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_Parser_OpenActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_ParserLayout = new javax.swing.GroupLayout(jPanel_Parser); jPanel_Parser.setLayout(jPanel_ParserLayout); jPanel_ParserLayout.setHorizontalGroup(jPanel_ParserLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_ParserLayout.createSequentialGroup().addContainerGap() .addGroup(jPanel_ParserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(parserProgress, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_ParserLayout.createSequentialGroup() .addComponent(jButton_Parser_Open, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jTextField_Parser, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap())); jPanel_ParserLayout .setVerticalGroup(jPanel_ParserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_ParserLayout.createSequentialGroup().addGap(3, 3, 3) .addGroup(jPanel_ParserLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jTextField_Parser).addComponent(jButton_Parser_Open, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(parserProgress, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createEtchedBorder(), "Game Viewer", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP)); jButton_PreviousGame.setText(""); jButton_PreviousGame.setToolTipText("Beginning of Game"); jButton_PreviousGame.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_PreviousGameActionPerformed(evt); } }); jButton_Next_Game.setText(""); jButton_Next_Game.setToolTipText("End of Game"); jButton_Next_Game.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_Next_GameActionPerformed(evt); } }); jButton_Previous_Ply.setText(""); jButton_Previous_Ply.setToolTipText("Previous Ply"); jButton_Previous_Ply.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_Previous_PlyActionPerformed(evt); } }); jButton_Next_Ply.setText(""); jButton_Next_Ply.setToolTipText("Next Ply"); jButton_Next_Ply.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_Next_PlyActionPerformed(evt); } }); jTextArea_Game_Viewer.setContentType("text/html"); // NOI18N jTextArea_Game_Viewer.setFont(new java.awt.Font("Monospaced", 0, 24)); // NOI18N jScrollPane2.setViewportView(jTextArea_Game_Viewer); Ply_Label.setText("Ply: "); Game_Label.setText("Game: "); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel1Layout.createSequentialGroup().addComponent(jScrollPane2).addContainerGap()) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jButton_PreviousGame) .addGap(18, 18, 18) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton_Previous_Ply, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Game_Label)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 89, Short.MAX_VALUE) .addGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jButton_Next_Ply).addGap(18, 18, 18) .addComponent(jButton_Next_Game)) .addComponent(Ply_Label)) .addGap(11, 11, 11))))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(jScrollPane2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton_PreviousGame) .addComponent(jButton_Previous_Ply, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton_Next_Ply, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton_Next_Game)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(Game_Label).addComponent(Ply_Label)) .addGap(6, 6, 6))); Variable_Viewer_Panel.setBorder(javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createEtchedBorder(), "Variable View", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP)); jScrollPane3.setMaximumSize(new java.awt.Dimension(75, 100)); Variable_Viewer_Textpane.setEnabled(false); jScrollPane1.setViewportView(Variable_Viewer_Textpane); jScrollPane3.setViewportView(jScrollPane1); javax.swing.GroupLayout Variable_Viewer_PanelLayout = new javax.swing.GroupLayout(Variable_Viewer_Panel); Variable_Viewer_Panel.setLayout(Variable_Viewer_PanelLayout); Variable_Viewer_PanelLayout .setHorizontalGroup( Variable_Viewer_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(Variable_Viewer_PanelLayout.createSequentialGroup().addContainerGap() .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); Variable_Viewer_PanelLayout.setVerticalGroup(Variable_Viewer_PanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(Variable_Viewer_PanelLayout.createSequentialGroup().addContainerGap() .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 339, Short.MAX_VALUE) .addContainerGap())); Graph_Panel.setBorder(javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createEtchedBorder(), "Graph Viewer", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP)); Variable_Chooser.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select Variable..." })); Variable_Chooser.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Variable_ChooserActionPerformed(evt); } }); graphFrame.setEnabled(false); graphFrame.setVisible(true); javax.swing.GroupLayout graphFrameLayout = new javax.swing.GroupLayout(graphFrame.getContentPane()); graphFrame.getContentPane().setLayout(graphFrameLayout); graphFrameLayout.setHorizontalGroup(graphFrameLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); graphFrameLayout.setVerticalGroup(graphFrameLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); javax.swing.GroupLayout Graph_PanelLayout = new javax.swing.GroupLayout(Graph_Panel); Graph_Panel.setLayout(Graph_PanelLayout); Graph_PanelLayout.setHorizontalGroup(Graph_PanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Graph_PanelLayout.createSequentialGroup() .addContainerGap() .addGroup(Graph_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(graphFrame).addComponent(Variable_Chooser, 0, 371, Short.MAX_VALUE)) .addContainerGap())); Graph_PanelLayout.setVerticalGroup(Graph_PanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(Graph_PanelLayout.createSequentialGroup().addContainerGap() .addComponent(Variable_Chooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(graphFrame).addContainerGap())); pattern_Button.setText("Find Patterns"); pattern_Button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { pattern_ButtonActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addComponent(pattern_Button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addComponent(pattern_Button, javax.swing.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE) .addContainerGap())); pattern_Button1.setText("Write to File"); pattern_Button1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { pattern_Button1ActionPerformed(evt); } }); javax.swing.GroupLayout writerPanelLayout = new javax.swing.GroupLayout(writerPanel); writerPanel.setLayout(writerPanelLayout); writerPanelLayout.setHorizontalGroup(writerPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(writerPanelLayout.createSequentialGroup().addContainerGap() .addComponent(pattern_Button1, javax.swing.GroupLayout.DEFAULT_SIZE, 368, Short.MAX_VALUE) .addContainerGap())); writerPanelLayout.setVerticalGroup(writerPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(writerPanelLayout.createSequentialGroup().addContainerGap().addComponent(pattern_Button1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); jMenu1.setText("File"); jMenu_Open.setText("Open"); jMenu_Open.setAccelerator(KeyStroke.getKeyStroke('O', CTRL_DOWN_MASK)); jMenu_Open.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenu_OpenActionPerformed(evt); } }); jMenu1.add(jMenu_Open); jMenuBar1.add(jMenu1); jMenu2.setText("Game"); jMenu_Game.setText("Game"); jMenu_Game.setAccelerator(KeyStroke.getKeyStroke('G', CTRL_DOWN_MASK)); jMenu_Game.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenu_GameActionPerformed(evt); } }); jMenu2.add(jMenu_Game); jMenu_Ply.setAccelerator(KeyStroke.getKeyStroke('T', CTRL_DOWN_MASK)); jMenu_Ply.setText("Ply"); jMenu_Ply.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenu_PlyActionPerformed(evt); } }); jMenu2.add(jMenu_Ply); Graphs_MenuItem.setText("Display Graphs"); Graphs_MenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Graphs_MenuItemActionPerformed(evt); } }); jMenu2.add(Graphs_MenuItem); jMenuBar1.add(jMenu2); 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().addGap(24, 24, 24) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(Variable_Viewer_Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_Parser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(writerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(Graph_Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(jPanel_Parser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(Variable_Viewer_Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(Graph_Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(writerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(133, 133, 133))); pack(); }
From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java
/** * Creates a new RegistryBrowser object. *///from w w w . ja v a2 s .c om @SuppressWarnings("unchecked") private RegistryBrowser() { instance = this; classLoader = getClass().getClassLoader(); // new // JAXRBrowserClassLoader(getClass().getClassLoader()); Thread.currentThread().setContextClassLoader(classLoader); /* * try { classLoader.loadClass("javax.xml.soap.SOAPMessage"); } catch * (ClassNotFoundException e) { * log.error("Could not find class javax.xml.soap.SOAPMessage", e); } */ UIManager.addPropertyChangeListener(new UISwitchListener(getRootPane())); // add listener for 'locale' bound property addPropertyChangeListener(PROPERTY_LOCALE, this); menuBar = new JMenuBar(); fileMenu = new JMenu(); editMenu = new JMenu(); viewMenu = new JMenu(); helpMenu = new JMenu(); JSeparator JSeparator1 = new JSeparator(); newItem = new JMenuItem(); importItem = new JMenuItem(); saveItem = new JMenuItem(); saveAsItem = new JMenuItem(); exitItem = new JMenuItem(); cutItem = new JMenuItem(); copyItem = new JMenuItem(); pasteItem = new JMenuItem(); aboutItem = new JMenuItem(); setJMenuBar(menuBar); setTitle(resourceBundle.getString("title.registryBrowser.java")); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); getContentPane().setLayout(new BorderLayout(0, 0)); // Scale window to be centered using 70% of screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); setBounds((int) (dim.getWidth() * .15), (int) (dim.getHeight() * .1), (int) (dim.getWidth() * .7), (int) (dim.getHeight() * .75)); setVisible(false); saveFileDialog.setMode(FileDialog.SAVE); saveFileDialog.setTitle(resourceBundle.getString("dialog.save.title")); GridBagLayout gb = new GridBagLayout(); topPanel.setLayout(gb); getContentPane().add("North", topPanel); GridBagConstraints c = new GridBagConstraints(); toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0)); toolbarPanel.setBounds(0, 0, 488, 29); discoveryToolBar = createDiscoveryToolBar(); toolbarPanel.add(discoveryToolBar); // c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.5; c.weighty = 0.5; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 0); gb.setConstraints(toolbarPanel, c); topPanel.add(toolbarPanel); // Panel containing context info like registry location and user context JPanel contextPanel = new JPanel(); GridBagLayout gb1 = new GridBagLayout(); contextPanel.setLayout(gb1); locationLabel = new JLabel(resourceBundle.getString("label.registryLocation")); // locationLabel.setPreferredSize(new Dimension(80, 23)); // c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.5; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 0, 0); gb1.setConstraints(locationLabel, c); // contextPanel.setBackground(Color.green); contextPanel.add(locationLabel); selectAnItemText = new ItemText(selectAnItem); registryCombo.addItem(selectAnItemText.toString()); ConfigurationType uiConfigurationType = UIUtility.getInstance().getConfigurationType(); RegistryURIListType urlList = uiConfigurationType.getRegistryURIList(); List<String> urls = urlList.getRegistryURI(); Iterator<String> urlsIter = urls.iterator(); while (urlsIter.hasNext()) { ItemText url = new ItemText(urlsIter.next()); registryCombo.addItem(url.toString()); } registryCombo.setEditable(true); registryCombo.setEnabled(true); registryCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final String url = (String) registryCombo.getSelectedItem(); if ((url == null) || (url.equals(selectAnItem))) { return; } // Clean tabbedPaneParent. Will create new content tabbedPaneParent.removeAll(); conceptsTreeDialog = null; ConceptsTreeDialog.clearCache(); // design: // 1. connect and construct tabbedPane in a now swing thread // 2. add tabbedPane in swing thread // 3. call reloadModel that should use WingWorkers final SwingWorker worker1 = new SwingWorker(RegistryBrowser.this) { public Object doNonUILogic() { try { // Try to connect if (connectToRegistry(url)) { return new JBTabbedPane(); } } catch (JAXRException e1) { displayError(e1); } return null; } public void doUIUpdateLogic() { tabbedPane = (JBTabbedPane) get(); if (tabbedPane != null) { tabbedPaneParent.add(tabbedPane, BorderLayout.CENTER); tabbedPane.reloadModel(); try { // DBH 1/30/04 - Add the submissions panel if // the user is authenticated. ConnectionImpl connection = RegistryBrowser.client.connection; boolean newValue = connection.isAuthenticated(); firePropertyChange(PROPERTY_AUTHENTICATED, false, newValue); getRootPane().updateUI(); } catch (JAXRException e1) { displayError(e1); } } } }; worker1.start(); } }); // c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.9; c.weighty = 0.5; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 0, 5, 0); gb1.setConstraints(registryCombo, c); contextPanel.add(registryCombo); JLabel currentUserLabel = new JLabel(resourceBundle.getString("label.currentUser"), SwingConstants.TRAILING); c.gridx = 2; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 5, 0); gb1.setConstraints(currentUserLabel, c); // contextPanel.add(currentUserLabel); currentUserText.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { @SuppressWarnings("unused") String text = currentUserText.getText(); } }); currentUserText.setEditable(false); c.gridx = 3; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.9; c.weighty = 0.5; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 5, 5); gb1.setConstraints(currentUserText, c); // contextPanel.add(currentUserText); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.9; c.weighty = 0.5; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 0, 0, 0); gb.setConstraints(contextPanel, c); topPanel.add(contextPanel, c); tabbedPaneParent.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); tabbedPaneParent.setLayout(new BorderLayout()); tabbedPaneParent.setToolTipText(resourceBundle.getString("tabbedPane.tip")); getContentPane().add("Center", tabbedPaneParent); fileMenu.setText(resourceBundle.getString("menu.file")); fileMenu.setActionCommand("File"); fileMenu.setMnemonic((int) 'F'); menuBar.add(fileMenu); saveItem.setHorizontalTextPosition(SwingConstants.TRAILING); saveItem.setText(resourceBundle.getString("menu.save")); saveItem.setActionCommand("Save"); saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)); saveItem.setMnemonic((int) 'S'); // fileMenu.add(saveItem); fileMenu.add(JSeparator1); importItem.setText(resourceBundle.getString("menu.import")); importItem.setActionCommand("Import"); importItem.setMnemonic((int) 'I'); importItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RegistryBrowser.setWaitCursor(); importFromFile(); RegistryBrowser.setDefaultCursor(); } }); fileMenu.add(importItem); exitItem.setText(resourceBundle.getString("menu.exit")); exitItem.setActionCommand("Exit"); exitItem.setMnemonic((int) 'X'); fileMenu.add(exitItem); editMenu.setText(resourceBundle.getString("menu.edit")); editMenu.setActionCommand("Edit"); editMenu.setMnemonic((int) 'E'); // menuBar.add(editMenu); cutItem.setHorizontalTextPosition(SwingConstants.TRAILING); cutItem.setText(resourceBundle.getString("menu.cut")); cutItem.setActionCommand("Cut"); cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK)); cutItem.setMnemonic((int) 'T'); editMenu.add(cutItem); copyItem.setHorizontalTextPosition(SwingConstants.TRAILING); copyItem.setText(resourceBundle.getString("menu.copy")); copyItem.setActionCommand("Copy"); copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK)); copyItem.setMnemonic((int) 'C'); editMenu.add(copyItem); pasteItem.setHorizontalTextPosition(SwingConstants.TRAILING); pasteItem.setText(resourceBundle.getString("menu.paste")); pasteItem.setActionCommand("Paste"); pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK)); pasteItem.setMnemonic((int) 'P'); editMenu.add(pasteItem); viewMenu.setText(resourceBundle.getString("menu.view")); viewMenu.setActionCommand("view"); viewMenu.setMnemonic((int) 'V'); themeMenu = new MetalThemeMenu(resourceBundle.getString("menu.theme"), themes); viewMenu.add(themeMenu); menuBar.add(viewMenu); helpMenu.setText(resourceBundle.getString("menu.help")); helpMenu.setActionCommand("Help"); helpMenu.setMnemonic((int) 'H'); menuBar.add(helpMenu); aboutItem.setHorizontalTextPosition(SwingConstants.TRAILING); aboutItem.setText(resourceBundle.getString("menu.about")); aboutItem.setActionCommand("About..."); aboutItem.setMnemonic((int) 'A'); aboutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object[] aboutArgs = { BROWSER_VERSION }; MessageFormat form = new MessageFormat(resourceBundle.getString("dialog.about.text")); JOptionPane.showMessageDialog(RegistryBrowser.this, form.format(aboutArgs), resourceBundle.getString("dialog.about.title"), JOptionPane.INFORMATION_MESSAGE); } }); helpMenu.add(aboutItem); // REGISTER_LISTENERS SymWindow aSymWindow = new SymWindow(); this.addWindowListener(aSymWindow); SymAction lSymAction = new SymAction(); saveItem.addActionListener(lSymAction); exitItem.addActionListener(lSymAction); SwingUtilities.updateComponentTreeUI(getContentPane()); SwingUtilities.updateComponentTreeUI(menuBar); SwingUtilities.updateComponentTreeUI(fileChooser); // Auto select the registry that is configured to connect to by default String selectedIndexStr = ProviderProperties.getInstance() .getProperty("jaxr-ebxml.registryBrowser.registryLocationCombo.initialSelectionIndex", "0"); int index = Integer.parseInt(selectedIndexStr); try { registryCombo.setSelectedIndex(index); } catch (IllegalArgumentException e) { Object[] invalidIndexArguments = { new Integer(index) }; MessageFormat form = new MessageFormat(resourceBundle.getString("message.error.invalidIndex")); displayError(form.format(invalidIndexArguments), e); } }