java.awt.event.ActionEvent Java Examples

The following examples show how to use java.awt.event.ActionEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SampleTree.java    From openjdk-jdk9 with GNU General Public License v2.0 8 votes vote down vote up
/**
 * Removes the selected item as long as it isn't root.
 */
public void actionPerformed(ActionEvent e) {
    TreePath[] selected = getSelectedPaths();

    if (selected != null && selected.length > 0) {
        TreePath shallowest;

        // The remove process consists of the following steps:
        // 1 - find the shallowest selected TreePath, the shallowest
        //     path is the path with the smallest number of path
        //     components.
        // 2 - Find the siblings of this TreePath
        // 3 - Remove from selected the TreePaths that are descendants
        //     of the paths that are going to be removed. They will
        //     be removed as a result of their ancestors being
        //     removed.
        // 4 - continue until selected contains only null paths.
        while ((shallowest = findShallowestPath(selected)) != null) {
            removeSiblings(shallowest, selected);
        }
    }
}
 
Example #2
Source File: MenuComponent.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
void dispatchEventImpl(AWTEvent e) {
    EventQueue.setCurrentEventAndMostRecentTime(e);

    Toolkit.getDefaultToolkit().notifyAWTEventListeners(e);

    if (newEventsOnly ||
        (parent != null && parent instanceof MenuComponent &&
         ((MenuComponent)parent).newEventsOnly)) {
        if (eventEnabled(e)) {
            processEvent(e);
        } else if (e instanceof ActionEvent && parent != null) {
            e.setSource(parent);
            ((MenuComponent)parent).dispatchEvent(e);
        }

    } else { // backward compatibility
        Event olde = e.convertToOld();
        if (olde != null) {
            postEvent(olde);
        }
    }
}
 
Example #3
Source File: TopComponentTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testCanTCGarbageCollectWhenActionInMapAndAssignLookup() {
    TopComponent tc = new TopComponent();
    class CAA extends AbstractAction implements
            ContextAwareAction {
        public void actionPerformed(ActionEvent arg0) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Action createContextAwareInstance(Lookup actionContext) {
            return this;
        }

    }
    tc.associateLookup(Lookups.fixed(tc.getActionMap(), tc));
    ContextAwareAction del = new CAA();
    ContextAwareAction context = Actions.context(Integer.class, true, true, del, null, "DisplayName", null, true);
    Action a = context.createContextAwareInstance(tc.getLookup());
    tc.getActionMap().put("key", a);

    WeakReference<Object> ref = new WeakReference<Object>(tc);
    tc = null;
    a = null;
    del = null;
    context = null;
    assertGC("Can the component GC?", ref);
}
 
Example #4
Source File: AssignmentDeleteAction.java    From ganttproject with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
  final ResourceAssignment[] context = myContext.getResourceAssignments();
  if (context != null && context.length > 0) {
    Choice choice = myUIFacade.showConfirmationDialog(getI18n("msg23") + " " + StringUtils.getDisplayNames(context)
        + "?", getI18n("warning"));
    if (choice == Choice.YES) {
      myUIFacade.getUndoManager().undoableEdit(getLocalizedDescription(), new Runnable() {
        @Override
        public void run() {
          deleteAssignments(context);
          myUIFacade.refresh();
        }
      });
    }
  }
}
 
Example #5
Source File: SwingFXWebView.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
private void initComponents(){

        jfxPanel = new JFXPanel();
        createScene();

        setLayout(new BorderLayout());
        add(jfxPanel, BorderLayout.CENTER);

        swingButton = new JButton();
        swingButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                Platform.runLater(new Runnable() {

                    @Override
                    public void run() {
                        webEngine.reload();
                    }
                });
            }
        });
        swingButton.setText("Reload");

        add(swingButton, BorderLayout.SOUTH);
    }
 
Example #6
Source File: TroopTableTab.java    From dsworkbench with Apache License 2.0 6 votes vote down vote up
/**
 * Creates new form TroopTableTab
 *
 * @param pTroopSet
 * @param pActionListener
 */
public TroopTableTab(String pTroopSet, final ActionListener pActionListener) {
    actionListener = pActionListener;
    sTroopSet = pTroopSet;
    initComponents();
    jScrollPane1.setViewportView(jxTroopTable);
    mSupportDetailsDialog = new SupportDetailsDialog(DSWorkbenchTroopsFrame.getSingleton(), true);
    mTroopDetailsDialog = new TroopDetailsDialog(DSWorkbenchTroopsFrame.getSingleton(), true);
    if (!KEY_LISTENER_ADDED) {
        KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
        KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
        jxTroopTable.registerKeyboardAction(pActionListener, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        jxTroopTable.registerKeyboardAction(pActionListener, "BBCopy", bbCopy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        jxTroopTable.getActionMap().put("find", new AbstractAction() {

            @Override
            public void actionPerformed(ActionEvent e) {
                pActionListener.actionPerformed(new ActionEvent(jxTroopTable, 0, "Find"));
            }
        });

        KEY_LISTENER_ADDED = true;
    }
    jxTroopTable.getSelectionModel().addListSelectionListener(TroopTableTab.this);
    //   jTroopAmountList.setCellRenderer(new TroopAmountListCellRenderer());
}
 
Example #7
Source File: SyntaxEditorKit.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
public void actionPerformed(ActionEvent event) {
    JTextComponent target = getTextComponent(event);
    if (target != null) {
        String line = SyntaxUtil.getLine(target);
        /**
         * Perform Smart Indentation:  pos must be on a line: this method will
         * use the previous lines indentation (number of spaces before any non-space
         * character or end of line) and return that as the prefix.
         */
        String indent = "";
        if (line != null && line.length() > 0) {
        	int i = 0;
        	while (i < line.length() && line.charAt(i) == ' ') {
        		i++;
        	}

        	indent = line.substring(0, i);
        }

        target.replaceSelection("\n" + indent);
    }
}
 
Example #8
Source File: ChangedFilesDialog.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/** 
 * Constructor 
 * @param tool tool to execute task and log messages in status window
 * @param list list of domain files that have changes
 */
public ChangedFilesDialog(PluginTool tool, ArrayList<DomainFile> list) { 
	super("Save Changed Files?", true);
	this.tool = tool;
	this.fileList = list;
	addWorkPanel(buildMainPanel());

	JButton saveButton = new JButton("Save");
	saveButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			save();
		}
	});
	saveButton.setToolTipText("Save files that have selected check boxes"); 
	addButton(saveButton);				
       addCancelButton();	
}
 
Example #9
Source File: DefaultPlotEditor.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
     * Handles user actions generated within the panel.
     * @param event     the event
     */
    @Override
    public void actionPerformed(ActionEvent event) {
        String command = event.getActionCommand();
        if (command.equals("BackgroundPaint")) {
            attemptBackgroundPaintSelection();
        }
        else if (command.equals("OutlineStroke")) {
            attemptOutlineStrokeSelection();
        }
        else if (command.equals("OutlinePaint")) {
            attemptOutlinePaintSelection();
        }
//        else if (command.equals("Insets")) {
//            editInsets();
//        }
        else if (command.equals("Orientation")) {
            attemptOrientationSelection();
        }
        else if (command.equals("DrawLines")) {
            attemptDrawLinesSelection();
        }
        else if (command.equals("DrawShapes")) {
            attemptDrawShapesSelection();
        }
    }
 
Example #10
Source File: SettingsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages("TIT_CustomGradle=Select Gradle Distribution")
private void btUseCustomGradleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUseCustomGradleActionPerformed
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(Bundle.TIT_CustomGradle());
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setFileHidingEnabled(false);
    String path = tfUseCustomGradle.getText();
    if (path == null || path.trim().length() == 0) {
        path = GradleSettings.getDefault().getGradleUserHome().getAbsolutePath();
    }
    if (path.length() > 0) {
        File f = new File(path);
        if (f.exists()) {
            chooser.setSelectedFile(f);
        }
    }
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
        File distDir = chooser.getSelectedFile();
        tfUseCustomGradle.setText(distDir.getAbsolutePath());
    }
}
 
Example #11
Source File: Editor.java    From brModelo with GNU General Public License v3.0 6 votes vote down vote up
public void DoAction(ActionEvent ev) {
    //setTextoDica("");
    if (diagramaAtual != null) {
        diagramaAtual.DoAction(ev);
        boolean eacao = false;
        Acao ac = null;
        if (((AbstractButton) ev.getSource()).getAction() instanceof Acao) {
            eacao = true;
            ac = (Acao) ((AbstractButton) ev.getSource()).getAction();
            try {
                setTextoDica(null, ac.getValue(Action.SHORT_DESCRIPTION).toString());
            } finally {
            }
        }
        if (ev.getSource() instanceof JMenuItem) {
            if (eacao) {
                controler.SelecioneForAction(ac);
            }
        }
    }
}
 
Example #12
Source File: AbstractToolbarFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void actionPerformed (ActionEvent ae) {
    JComponent item = (JComponent) ae.getSource();
    String actionCommand = (String) item.getClientProperty(KEY_ACTION);
    String context = (String) item.getClientProperty(KEY_CONTAINERCTX);
    
    getEngine().notifyWillPerform (actionCommand, context);
    
    Action action = getEngine().getAction(context, actionCommand); 
    
    if (action.isEnabled()) {
        ActionEvent event = new ActionEvent (item, 
        ActionEvent.ACTION_PERFORMED, actionCommand);
        action.actionPerformed(event);
    }
    
    getEngine().notifyPerformed (actionCommand, context);
}
 
Example #13
Source File: ActionMenuItem.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(final ActionEvent e) {
  final IdeFocusManager fm = IdeFocusManager.findInstanceByContext(myContext);
  final ActionCallback typeAhead = new ActionCallback();
  final String id = ActionManager.getInstance().getId(myAction.getAction());
  if (id != null) {
    FeatureUsageTracker.getInstance().triggerFeatureUsed("context.menu.click.stats." + id.replace(' ', '.'));
  }
  fm.typeAheadUntil(typeAhead, getText());
  fm.runOnOwnContext(myContext, () -> {
    final AnActionEvent event =
            new AnActionEvent(new MouseEvent(ActionMenuItem.this, MouseEvent.MOUSE_PRESSED, 0, e.getModifiers(), getWidth() / 2, getHeight() / 2, 1, false),
                              myContext, myPlace, myPresentation, ActionManager.getInstance(), e.getModifiers(), true, false);
    final AnAction menuItemAction = myAction.getAction();
    if (ActionUtil.lastUpdateAndCheckDumb(menuItemAction, event, false)) {
      ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
      actionManager.fireBeforeActionPerformed(menuItemAction, myContext, event);
      fm.doWhenFocusSettlesDown(typeAhead::setDone);
      ActionUtil.performActionDumbAware(menuItemAction, event);
      actionManager.queueActionPerformedEvent(menuItemAction, myContext, event);
    }
    else {
      typeAhead.setDone();
    }
  });
}
 
Example #14
Source File: ExpressionMetaDataEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Invoked when an action occurs.
 */
public void actionPerformed( final ActionEvent e ) {
  StringBuffer completeText = new StringBuffer();
  final int[] selectedRows = expressionsTable.getSelectedRows();
  for ( int i = 0; i < selectedRows.length; i++ ) {
    final int selectedRow = selectedRows[ i ];
    final int modelRow = expressionsTable.convertRowIndexToModel( selectedRow );
    final EditableExpressionMetaData data = metaData[ modelRow ];
    data.sort( expressionsTableModel.getLocale() );
    final String text = data.printBundleText( expressionsTableModel.getLocale() );
    System.out.println( "# Printing metadata for " + metaData[ modelRow ].getName() );
    System.out.println( text );
    completeText.append( "# Printing metadata for " + metaData[ modelRow ].getName() );
    completeText.append( "\n" );
    completeText.append( text );
  }

  dialog.showText( completeText.toString() );
}
 
Example #15
Source File: TimelineEditor.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
private void addAnimationObjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addAnimationObjectActionPerformed
    AnimationObjectEditor editor = new AnimationObjectEditor(res, null, getValue(duration));
    editor.setStartTime(timeline.getValue());
    int ok = JOptionPane.showConfirmDialog(this, editor, "Add", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if(ok == JOptionPane.OK_OPTION) {
        ((AnimationObjectTableModel)animationObjectList.getModel()).addElement(editor.getAnimationObject());
        Timeline t = (Timeline)res.getImage(name);
        AnimationObject[] animations = new AnimationObject[t.getAnimationCount() + 1];
        for(int iter = 0 ; iter < animations.length - 1 ; iter++) {
            animations[iter] = t.getAnimation(iter);
        }
        animations[animations.length - 1] = editor.getAnimationObject();
        Timeline nt = Timeline.createTimeline(getValue(duration), animations,
                new com.codename1.ui.geom.Dimension(getValue(width), getValue(height)));
        nt.setPause(t.isPause());
        nt.setTime(t.getTime());
        setImage(nt);
    }
}
 
Example #16
Source File: SampleTree.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** Construct a menu. */
private JMenuBar constructMenuBar() {
    JMenu menu;
    JMenuBar menuBar = new JMenuBar();
    JMenuItem menuItem;

    /* Good ol exit. */
    menu = new JMenu("File");
    menuBar.add(menu);

    menuItem = menu.add(new JMenuItem("Exit"));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });

    /* Tree related stuff. */
    menu = new JMenu("Tree");
    menuBar.add(menu);

    menuItem = menu.add(new JMenuItem("Add"));
    menuItem.addActionListener(new AddAction());

    menuItem = menu.add(new JMenuItem("Insert"));
    menuItem.addActionListener(new InsertAction());

    menuItem = menu.add(new JMenuItem("Reload"));
    menuItem.addActionListener(new ReloadAction());

    menuItem = menu.add(new JMenuItem("Remove"));
    menuItem.addActionListener(new RemoveAction());

    return menuBar;
}
 
Example #17
Source File: RestoreDockingAction.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent event) {        
      int option = JOptionPane.showConfirmDialog(Globals.getMainFrame(), I18NSupport.getString("docking.restart"), "", JOptionPane.YES_NO_OPTION);
      if (option != JOptionPane.YES_OPTION) {
          return;
      }
      // remove current workspaces
      new File(WorkspaceManager.QUERY_WORKSPACE_FILE).delete();
      new File(WorkspaceManager.REPORT_WORKSPACE_FILE).delete();

      try {
	WorkspaceManager.getInstance().restoreWorkspaces();
} catch (IOException e) {
	LOG.error(e.getMessage(), e);
}
  }
 
Example #18
Source File: JPlotterPanel.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
private void jAdvancedOptionsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAdvancedOptionsButtonActionPerformed
   OpenSimDialog  advDlg=DialogUtils.createDialogForPanelWithParent(getFrame(), jAdvancedPanel, "Advanced Options");
   DialogUtils.addStandardButtons(advDlg);
   advDlg.setModal(true);
   advDlg.setVisible(true);
   if (advDlg.getDialogReturnValue()==OpenSimDialog.OK_OPTION){
       setClamp(jClampCheckBox.isSelected());
       setActivationOverride(jActivationOverrideCheckBox.isSelected());
       updateSummary();
   }
}
 
Example #19
Source File: DefaultCaret.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adjusts the caret location based on the MouseEvent.
 */
private void adjustCaret(MouseEvent e) {
    if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0 &&
        getDot() != -1) {
        moveCaret(e);
    } else if (!e.isPopupTrigger()) {
        positionCaret(e);
    }
}
 
Example #20
Source File: TaskShopDataGeneratorAction.java    From gameserver with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
	SwingUtilities.invokeLater(new Runnable(){
		public void run() {
			//MainPanel.getInstance().setCenterPanel(TaskShopDataGeneratorPanel.getInstance());
			MainPanel.getInstance().setCenterPanel(TaskEquipmentExportPanel.getInstance());
		}
	});
}
 
Example #21
Source File: ProfilerTableActions.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private Action selectLastColumnAction() {
    return new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            ProfilerColumnModel cModel = table._getColumnModel();
            if (table.getRowCount() == 0 || cModel.getVisibleColumnCount() == 0) return;
            
            int row = table.getSelectedRow();
            table.selectColumn(cModel.getLastVisibleColumn(), row != -1);
            if (row == -1) table.selectRow(0, true);
        }
    };
}
 
Example #22
Source File: DrawPhase.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ae) {

	GameManager.getInstance().getActualTurn().setCurrentPhase(Turn.PHASES.DRAW);
	GamePanelGUI.getInstance().getTurnsPanel().disableButtonsTo((JButton) ae.getSource());
	new DrawActions().actionPerformed(ae);
	setEnabled(false);

}
 
Example #23
Source File: MinifyKeyAction.java    From minifierbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    MinifyProperty minifyProperty = MinifyProperty.getInstance();
    DataObject dob = TopComponent.getRegistry().getActivated().getLookup().lookup(DataObject.class);

    if (dob != null && minifyProperty.isEnableShortKeyAction()) {
        FileObject fileObject = dob.getPrimaryFile();//       p = FileOwnerQuery.getOwner(fo);
        boolean allowAction = true;

        if (minifyProperty.isEnableShortKeyActionConfirmBox()) {
            NotifyDescriptor.Confirmation nd
                    = new NotifyDescriptor.Confirmation(
                            "Are you sure to minify " + fileObject.getNameExt() + " ?",
                            "Minify " + fileObject.getNameExt(),
                            NotifyDescriptor.YES_NO_OPTION);
            nd.setOptions(new Object[]{
                NotifyDescriptor.YES_OPTION,
                NotifyDescriptor.NO_OPTION});
            if (DialogDisplayer.getDefault().notify(nd).equals(NotifyDescriptor.NO_OPTION)) {
                allowAction = false;
            }
        }
        if (allowAction) {
            if (fileObject.isFolder()) {
                targetAction = new Minify(dob);
            } else {
                if (fileObject.getExt().equalsIgnoreCase("js")) {
                    targetAction = new JSMinify(dob);
                } else if (fileObject.getExt().equalsIgnoreCase("css")) {
                    targetAction = new CSSMinify(dob);
                } else if (fileObject.getExt().equalsIgnoreCase("html") || fileObject.getExt().equalsIgnoreCase("htm")) {
                    targetAction = new HTMLMinify(dob);
                }
            }
            targetAction.actionPerformed(e);
        }
    }
}
 
Example #24
Source File: LinkButton.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private void makeHyperLinkListener(final Action action) {
	actionLinkListener = new HyperlinkListener() {

		@Override
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == EventType.ACTIVATED) {
				action.actionPerformed(
						new ActionEvent(LinkButton.this, ActionEvent.ACTION_PERFORMED, e.getDescription()));
			}
		}
	};
	addHyperlinkListener(actionLinkListener);
}
 
Example #25
Source File: NodeJsPathPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages("NodeJsPathPanel.node.none=No node executable was found.")
private void nodeSearchButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_nodeSearchButtonActionPerformed
    assert EventQueue.isDispatchThread();
    for (String node : FileUtils.findFileOnUsersPath(NodeExecutable.NODE_NAMES)) {
        nodeTextField.setText(new File(node).getAbsolutePath());
        return;
    }
    // no node found
    StatusDisplayer.getDefault().setStatusText(Bundle.NodeJsPathPanel_node_none());
}
 
Example #26
Source File: TestOldHangul.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void run()  {
    Font ourFont = null;
    final String fontName = "UnBatangOdal.ttf";  // download from http://chem.skku.ac.kr/~wkpark/project/font/GSUB/UnbatangOdal/  and place in {user.home}/fonts/
    try {
        ourFont = Font.createFont(Font.TRUETYPE_FONT, new java.io.File(new java.io.File(System.getProperty("user.home"),"fonts"), fontName));
        ourFont = ourFont.deriveFont((float)48.0);
    } catch(Throwable t) {
        t.printStackTrace();
        System.err.println("Fail: " + t);
        return;
    }
    JFrame frame = new JFrame(System.getProperty("java.version"));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    final JTextArea label = new JTextArea("(empty)");
    label.setSize(400, 300);
    label.setBorder(new LineBorder(Color.black));
    label.setFont(ourFont);
    final String str = "\u110A\u119E\u11B7\u0020\u1112\u119E\u11AB\uAE00\u0020\u1100\u119E\u11F9\u0020\u112B\u119E\u11BC\n";

    if(AUTOMATIC_TEST) {  /* run the test automatically (else, manually) */
        label.setText(str);
    } else {
    JButton button = new JButton("Old Hangul");
    button.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
            label.setText(str);
        }
    });
    panel.add(button);
    }
    panel.add(label);

    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
}
 
Example #27
Source File: MailDialog.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method initializes jComboBox1	
 * 	
 * @return javax.swing.JComboBox	
 */    
private JComboBox<String> getJTagComboBox() {
	if (jTagComboBox == null) {
		jTagComboBox = new JComboBox<String>(tagNames);
		jTagComboBox.addActionListener(new java.awt.event.ActionListener() { 
			public void actionPerformed(java.awt.event.ActionEvent e) {
				JTextArea ta = getJTemplateTextArea();
				ta.insert("{" + (String) jTagComboBox.getSelectedItem() +
						"}",ta.getCaretPosition());
			}
		});
	}
	return jTagComboBox;
}
 
Example #28
Source File: SequencePopupMenuItem.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
private void initialize() {
    this.setText(
            extension.getMessages().getString("sequence.popupmenuitem.activeScanSequence"));

    this.addActionListener(
            new java.awt.event.ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        ScriptWrapper wrapper =
                                (ScriptWrapper)
                                        extScript
                                                .getScriptUI()
                                                .getSelectedNode()
                                                .getUserObject();
                        SequenceScript scr =
                                extScript.getInterface(wrapper, SequenceScript.class);
                        if (scr != null) {
                            extension.setDirectScanScript(wrapper);
                            scr.scanSequence();
                        } else {
                            String msg =
                                    extension
                                            .getMessages()
                                            .getString(
                                                    "sequence.popupmenuitem.script.error.interface");
                            View.getSingleton()
                                    .showMessageDialog(
                                            MessageFormat.format(msg, wrapper.getName()));
                        }
                    } catch (Exception ex) {
                        logger.warn(
                                "An exception occurred while starting an active scan for a sequence script:",
                                ex);
                    }
                }
            });
}
 
Example #29
Source File: DefaultEditorKit.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The operation to perform when this action is triggered.
 *
 * @param e the action event
 */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        target.cut();
    }
}
 
Example #30
Source File: DefaultEditorKit.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The operation to perform when this action is triggered.
 *
 * @param e the action event
 */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        if ((! target.isEditable()) || (! target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        target.replaceSelection("\t");
    }
}