List of usage examples for javax.swing Action actionPerformed
public void actionPerformed(ActionEvent e);
From source file:processing.app.Editor.java
protected void handleIndentOutdent(boolean indent) { if (indent) { int caretPosition = textarea.getCaretPosition(); boolean noSelec = !textarea.isSelectionActive(); // if no selection, focus on first char. if (noSelec) { try { int line = textarea.getCaretLineNumber(); int startOffset = textarea.getLineStartOffset(line); textarea.setCaretPosition(startOffset); } catch (BadLocationException e) { }/* w w w .j a v a2s . com*/ } // Insert Tab or Spaces.. Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.insertTabAction); action.actionPerformed(null); if (noSelec) { textarea.setCaretPosition(caretPosition); } } else { Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.rstaDecreaseIndentAction); action.actionPerformed(null); } }
From source file:processing.app.EditorTab.java
void handleCommentUncomment() { Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.rstaToggleCommentAction); action.actionPerformed(null); // XXX: RSyntaxDocument doesn't fire DocumentListener events, it should be fixed in RSyntaxTextArea? editor.updateUndoRedoState();/*from w w w. ja va 2s. c o m*/ }
From source file:processing.app.EditorTab.java
void handleIndentOutdent(boolean indent) { if (indent) { Action action = textarea.getActionMap().get(SketchTextAreaEditorKit.rtaIncreaseIndentAction); action.actionPerformed(null); } else {// ww w . j a va 2 s . c om Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.rstaDecreaseIndentAction); action.actionPerformed(null); } // XXX: RSyntaxDocument doesn't fire DocumentListener events, it should be fixed in RSyntaxTextArea? editor.updateUndoRedoState(); }
From source file:statechum.analysis.learning.Visualiser.java
public void construct(Graph g, LayoutOptions options) { if (!globalConfig.isAssertEnabled() && Boolean.getBoolean(globalConfig.getProperty(G_PROPERTIES.ASSERT_ENABLED))) { System.err.println("Pass the -ea argument to JVM to enable assertions"); }//from w ww. ja v a 2 s . co m // if (Boolean.valueOf(GlobalConfiguration.getConfiguration() .getProperty(GlobalConfiguration.G_PROPERTIES.CLOSE_TERMINATE))) this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); else if (Boolean.valueOf( GlobalConfiguration.getConfiguration().getProperty(GlobalConfiguration.G_PROPERTIES.ESC_TERMINATE))) this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); else this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); this.addWindowListener(new WindowEventHandler()); /* this.addComponentListener(new ComponentListener() { @Override public void componentShown(@SuppressWarnings("unused") ComponentEvent e) {} @Override public void componentResized(@SuppressWarnings("unused") ComponentEvent e) { if (viewer != null) viewer.getModel().getGraphLayout().resize(getSize()); } @Override public void componentMoved(@SuppressWarnings("unused") ComponentEvent e) {} @Override public void componentHidden(@SuppressWarnings("unused") ComponentEvent e) {} });*/ this.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent arg0) { Action act = keyToActionMap.get(arg0.getKeyCode()); if (act != null) { act.actionPerformed(null); } } @Override public void keyReleased(@SuppressWarnings("unused") KeyEvent arg0) {// this method is intentionally left blank - keypresses/releases are handled by the keyPressed method. } @Override public void keyTyped(@SuppressWarnings("unused") KeyEvent key) {// this method is intentionally left blank - keypresses/releases are handled by the keyPressed method. } }); popupMenu = new JPopupMenu(); // Icon loading is from http://www.javaworld.com/javaworld/javaqa/2000-06/03-qa-0616-icon.html Image icon = Toolkit.getDefaultToolkit() .getImage(GlobalConfiguration.getConfiguration().getProperty(G_PROPERTIES.RESOURCES) + File.separator + "icon.jpg"); if (icon != null) { setIconImage(icon); } setVisualiserKeyBindings(); setStateChumKeyBindings(this, propName, keyToActionMap); updatePopupMenu(popupMenu, keyToActionMap); //getContentPane().removeAll(); WindowPosition framePosition = globalConfig.loadFrame(propName); viewer = new VisualizationViewer( new DefaultVisualizationModel( new XMLPersistingLayout(propName >= 0 ? new FRLayout(g) : new KKLayout(g))), constructRenderer(g, options)); viewer.setBackground(Color.WHITE); final DefaultModalGraphMouse graphMouse = new XMLModalGraphMouse(); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); graphMouse.add(new PickingGraphMousePlugin()); viewer.setGraphMouse(graphMouse); viewer.setPickSupport(new ShapePickSupport()); viewer.addMouseListener(this); final GraphZoomScrollPane panel = new GraphZoomScrollPane(viewer); getContentPane().add(panel); pack(); viewer.setPreferredSize(getSize()); //viewer.getModel().getGraphLayout().initialize(getSize()); restoreLayout(true, currentGraph); setBounds(framePosition.getRect()); framesVisible.add(this);// register as an active frame. setVisible(true); }
From source file:tk.tomby.tedit.services.ActionManager.java
/** * DOCUMENT ME!// w ww . j a v a 2 s . c o m * * @param actionName DOCUMENT ME! * @param evt DOCUMENT ME! */ public static void invokeAction(String actionName, ActionEvent evt) { Action action = getAction(actionName); if (action != null) { action.actionPerformed(evt); } }
From source file:uk.co.modularaudio.componentdesigner.ComponentDesigner.java
public void go() { mainFrame.setVisible(true);//from ww w.jav a 2s . c o m final Action checkAudioConfigurationAction = mainFrameActions.getCheckAudioConfigurationAction(); final ActionEvent tmpActionEvent = new ActionEvent(this, 1, "blah"); checkAudioConfigurationAction.actionPerformed(tmpActionEvent); }
From source file:uk.co.modularaudio.componentdesigner.ComponentDesigner.java
public void registerCloseAction() throws DatastoreException { mainFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); mainFrame.addWindowListener(new WindowListener() { @Override//w w w. j av a2s . co m public void windowClosed(final WindowEvent e) { log.debug("Window closed event received"); } @Override public void windowOpened(final WindowEvent e) { try { log.debug("Window opening event received - setting thread to lowest priority."); ThreadUtils.setCurrentThreadPriority(MAThreadPriority.APPLICATION); if (log.isDebugEnabled()) { log.debug("Now set to " + MAThreadPriority.APPLICATION); } } catch (final Exception ie) { final String msg = "Exception caught setting gui thread priority: " + ie.toString(); log.error(msg, ie); } } @Override public void windowClosing(final WindowEvent e) { log.debug("Window closing event received."); final Action exitAction = mainFrameActions.getExitAction(); final ActionEvent exitActionEvent = new ActionEvent(e.getSource(), e.getID(), ""); exitAction.actionPerformed(exitActionEvent); } @Override public void windowIconified(final WindowEvent e) { } @Override public void windowDeiconified(final WindowEvent e) { } @Override public void windowActivated(final WindowEvent e) { } @Override public void windowDeactivated(final WindowEvent e) { } }); }
From source file:us.daveread.basicquery.BasicQuery.java
/** * Copy the selected data cells to the clipboard *//*w ww. jav a2s. co m*/ private void copySelectionToClipboard() { Action objlCopy; try { objlCopy = TransferHandler.getCopyAction(); objlCopy.actionPerformed(new ActionEvent(table, ActionEvent.ACTION_PERFORMED, (String) objlCopy.getValue(Action.NAME), EventQueue.getMostRecentEventTime(), 0)); } catch (Throwable any) { LOGGER.error("Failed to copy data to clipboard", any); JOptionPane.showMessageDialog(this, Resources.getString("errClipboardCopyDataText", any.getClass().getName(), any.getMessage() != null ? any.getMessage() : ""), Resources.getString("errClipboardCopyDataTitle"), JOptionPane.ERROR_MESSAGE); } }