Example usage for java.awt.event ActionEvent ActionEvent

List of usage examples for java.awt.event ActionEvent ActionEvent

Introduction

In this page you can find the example usage for java.awt.event ActionEvent ActionEvent.

Prototype

public ActionEvent(Object source, int id, String command) 

Source Link

Document

Constructs an ActionEvent object.

Usage

From source file:com.funambol.foundation.admin.FileSystemSyncSourceConfigPanel.java

/**
 * Create the panel// w ww .  j  ava 2 s .  c  o m
 * @throws Exception if error occures during creation of the panel
 */

private void init() {
    // set layout
    this.setLayout(null);

    // set properties of label, position and border
    //  referred to the title of the panel
    titledBorder1 = new TitledBorder("");

    panelName.setFont(titlePanelFont);
    panelName.setText("Edit File System SyncSource");
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder1);

    int y = 60;
    int dy = 30;

    sourceUriLabel.setText("Source URI: ");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(new Rectangle(14, y, 150, 18));
    sourceUriValue.setFont(defaultFont);
    sourceUriValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    nameLabel.setText("Name: ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(14, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    directoryLabel.setText("Source Directory: ");
    directoryLabel.setFont(defaultFont);
    directoryLabel.setBounds(new Rectangle(14, y, 150, 18));
    directoryValue.setFont(defaultFont);
    directoryValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    infoTypesLabel.setText("Supported types: ");
    infoTypesLabel.setFont(defaultFont);
    infoTypesLabel.setBounds(new Rectangle(14, y, 150, 18));
    infoTypesValue.setFont(defaultFont);
    infoTypesValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    infoVersionsLabel.setText("Supported versions: ");
    infoVersionsLabel.setFont(defaultFont);
    infoVersionsLabel.setBounds(new Rectangle(14, y, 150, 18));
    infoVersionsValue.setFont(defaultFont);
    infoVersionsValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    multiUserLabel.setText("MultiUser: ");
    multiUserLabel.setFont(defaultFont);
    multiUserLabel.setBounds(new Rectangle(14, y, 150, 18));
    multiUserValue.setSelected(false);
    multiUserValue.setBounds(167, y, 50, 25);

    y += dy;
    y += dy;

    confirmButton.setFont(defaultFont);
    confirmButton.setText("Add");
    confirmButton.setBounds(170, y, 70, 25);

    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    FileSystemSyncSourceConfigPanel.this
                            .actionPerformed(new ActionEvent(FileSystemSyncSourceConfigPanel.this,
                                    ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    FileSystemSyncSourceConfigPanel.this
                            .actionPerformed(new ActionEvent(FileSystemSyncSourceConfigPanel.this,
                                    ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage()));
            }
        }
    });

    // add all components to the panel
    this.add(panelName, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);
    this.add(nameLabel, null);
    this.add(nameValue, null);
    this.add(directoryLabel, null);
    this.add(directoryValue, null);
    this.add(infoTypesLabel, null);
    this.add(infoTypesValue, null);
    this.add(infoVersionsLabel, null);
    this.add(infoVersionsValue, null);
    this.add(multiUserLabel, null);
    this.add(multiUserValue, null);
    this.add(confirmButton, null);

}

From source file:pipeline.parameter_cell_views.FloatRangeSlider.java

public FloatRangeSlider() {
    super();//from   w w w .j  a v a 2 s  . c om
    addMouseWheelListener(e -> {

        int rotation = e.getWheelRotation();

        float[] float_values = (float[]) (currentParameter.getValue());
        currentValue0 = float_values[0];
        currentValue1 = float_values[1];
        minimum = float_values[2];
        maximum = float_values[3];

        float change = (currentValue1 - currentValue0 + 1) * rotation * Utils.getMouseWheelClickFactor();

        currentValue0 += change;
        currentValue1 += change;

        if (!((e.getModifiers() & java.awt.event.InputEvent.ALT_MASK) > 0)) {
            if (currentValue1 > maximum) {
                float difference = currentValue1 - currentValue0;
                currentValue1 = maximum;
                currentValue0 = currentValue1 - difference;
            }
            if (currentValue0 < minimum) {
                float difference = currentValue1 - currentValue0;
                currentValue0 = minimum;
                currentValue1 = currentValue0 + difference;
            }
        }

        currentParameter.setValue(new float[] { currentValue0, currentValue1, minimum, maximum });

        readInValuesFromParameter();
        updateDisplays();
        currentParameter.fireValueChanged(false, false, true);
    });
    nf.setGroupingUsed(true);
    nf.setMaximumFractionDigits(5);
    nf.setMaximumIntegerDigits(10);

    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;

    c.gridx = 0;
    c.gridy = 0;
    c.weighty = 1.0;
    c.weightx = 1.0;
    c.gridwidth = 4;

    cForHistogram = (GridBagConstraints) c.clone();

    panelForHistogram = new JPanel();
    panelForHistogram.setPreferredSize(new Dimension(200, 150));
    panelForHistogram.setLayout(new BorderLayout());

    c.gridx = 0;
    c.gridy = 1;// 1
    c.weighty = 0.0;
    c.weightx = 0.0;
    c.gridwidth = 4;
    add(Box.createRigidArea(new Dimension(0, 5)), c);

    slider = new RangeSlider(0, 20);
    slider.addChangeListener(new sliderListener());
    c.gridx = 0;
    c.gridy = 2;
    c.weighty = 0.0;
    c.weightx = 0.0;
    c.gridwidth = 4;
    add(slider, c);

    c.gridx = 0;
    c.gridy = 3;
    c.weighty = 0.0;
    c.weightx = 1.0;
    c.gridwidth = 4;
    Component comp = Box.createRigidArea(new Dimension(0, 10));
    ((JComponent) comp).setOpaque(true);
    add(comp, c);
    c.gridwidth = 1;

    final textBoxListener minMaxListener = new textBoxListener();

    currentTextValue0 = new JTextField("");
    currentTextValue1 = new JTextField("");
    currentTextValue0.addActionListener(new textBoxListenerTriggersUpdate());
    currentTextValue1.addActionListener(new textBoxListenerTriggersUpdate());
    Font smallerFont = new Font(currentTextValue0.getFont().getName(), currentTextValue0.getFont().getStyle(),
            currentTextValue0.getFont().getSize() - 2);
    textMinimum = new JTextField("0");
    textMinimum.setFont(smallerFont);
    textMinimum.addActionListener(minMaxListener);
    textMaximum = new JTextField("50");
    textMaximum.setFont(smallerFont);
    textMaximum.addActionListener(minMaxListener);
    textMaximum.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            minMaxListener.actionPerformed(new ActionEvent(textMaximum, 0, ""));
        }
    });
    textMinimum.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            minMaxListener.actionPerformed(new ActionEvent(textMinimum, 0, ""));
        }
    });

    textValueFrame = new JPanel();
    textValueFrame.setBackground(getBackground());
    textValueFrame.setLayout(new GridBagLayout());

    c.gridx = 0;
    c.gridy = 0;
    c.weighty = 1.0;
    c.weightx = 0.1;
    textValueFrame.add(textMinimum, c);

    c.gridx = 1;
    c.gridy = 0;
    c.weighty = 1.0;
    c.weightx = 0.3;
    textValueFrame.add(currentTextValue0, c);

    c.gridx = 2;
    c.gridy = 0;
    c.weighty = 1.0;
    c.weightx = 0.3;
    textValueFrame.add(currentTextValue1, c);

    c.gridx = 3;
    c.gridy = 0;
    c.weighty = 1.0;
    c.weightx = 0.1;
    textValueFrame.add(textMaximum, c);

    c.gridx = 0;
    c.gridy = 4;
    c.weighty = 0.0;
    c.weightx = 0.3;
    c.gridwidth = 4;
    add(textValueFrame, c);
    c.gridwidth = 1;

    parameterName = new JLabel("parameter");
    c.gridx = 0;
    c.gridy = 5;
    c.weighty = 0.0;
    c.weightx = 0.01;
    c.gridwidth = 1;
    add(parameterName, c);

    resetMin = new JButton("Min");
    resetMin.setActionCommand("Reset Min");
    resetMin.addActionListener(new buttonListener());
    resetMax = new JButton("Max");
    resetMax.setActionCommand("Reset Max");
    resetMax.addActionListener(new buttonListener());
    resetRange = new JButton("MinMax");
    resetRange.setActionCommand("Reset Range");
    resetRange.addActionListener(new buttonListener());

    c.gridx = 1;
    c.gridy = 5;
    c.weighty = 0.0;
    c.weightx = 0.2;
    c.gridwidth = 1;
    add(resetMin, c);

    c.gridx = 2;
    c.gridy = 5;
    c.weighty = 0.0;
    c.weightx = 0.2;
    c.gridwidth = 1;
    add(resetMax, c);

    c.gridx = 3;
    c.gridy = 5;
    c.weighty = 0.0;
    c.weightx = 0.2;
    c.gridwidth = 1;
    add(resetRange, c);
    // ,resetMax,resetRange;

}

From source file:com.googlecode.commons.swing.component.datetime.MiniDateCalendar.java

protected void fireActionListener() {
    ActionListener[] listeners = listenerList.getListeners(ActionListener.class);
    for (ActionListener l : listeners) {
        l.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, ""));
    }//from w w  w . j ava 2  s.  co m
}

From source file:com.mirth.connect.plugins.mllpmode.MLLPModeSettingsDialog.java

private void changeAbbreviation(DocumentEvent evt) {
    String text = "";

    try {/* www . j  a  va2s  .c om*/
        text = evt.getDocument().getText(0, evt.getDocument().getLength()).trim();
    } catch (BadLocationException e) {
    }

    if (evt.getDocument().equals(startOfMessageBytesField.getDocument())) {
        startOfMessageAbbreviation = TcpUtil.convertHexToAbbreviation(text);
        actionListener.actionPerformed(new ActionEvent(startOfMessageBytesField, ActionEvent.ACTION_PERFORMED,
                MLLPModeClientProvider.CHANGE_START_BYTES_COMMAND));
    } else if (evt.getDocument().equals(endOfMessageBytesField.getDocument())) {
        endOfMessageAbbreviation = TcpUtil.convertHexToAbbreviation(text);
        actionListener.actionPerformed(new ActionEvent(endOfMessageBytesField, ActionEvent.ACTION_PERFORMED,
                MLLPModeClientProvider.CHANGE_END_BYTES_COMMAND));
    } else if (evt.getDocument().equals(ackBytesField.getDocument())) {
        ackAbbreviation = TcpUtil.convertHexToAbbreviation(text);
    } else {
        nackAbbreviation = TcpUtil.convertHexToAbbreviation(text);
    }

    changeAbbreviation();
}

From source file:com.alvermont.terraj.fracplanet.ui.TerrainViewerFrame.java

/**
 * Called to initialize the display being managed by this object
 *//*from   www  .  j  a v  a  2 s . c om*/
public void initialize() {
    final MathUtils utils = new MathUtils(new Random(getAllParams().getTerrainParameters().getTerrainSeed()));

    this.pd = new ProgressDialog(this, false);

    // disable lightweight menus so they don't appear behind the GL canvas
    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
    /* // zzing 24 Feb 2013  We don't need this with JOGL 2
            try {
    JarLibraryLoader.setupPath();
            
    JarLibraryLoader.extractLibrary("jogl");
    JarLibraryLoader.extractLibrary("jogl_awt");
    JarLibraryLoader.extractLibrary("jogl_cg");
    JarLibraryLoader.extractLibrary("jogl_drihack");
            } catch (Exception e) {
    log.error("Failed to load native libraries from jar file", e);
            }
    */
    try {
        GLProfile glProfile = GLProfile.getDefault();
        System.out.println(glProfile);
        GLCapabilities cap = new GLCapabilities(glProfile);
        System.out.println(cap);
        GLCanvas c = new GLCanvas(cap);

        this.canvas = c;
        this.terrainPanel.add(this.canvas);

        //            System.out.println(this.canvas.getGL());

        //new GLCanvas(new GLCapabilities(GLProfile.getDefault()));
        /*GLProfile glprofile = GLProfile.getDefault();
        GLCapabilities glcapabilities = new GLCapabilities( glprofile );
        final GLCanvas glcanvas = new GLCanvas( glcapabilities );
        this.canvas = glcanvas; */
    } catch (Throwable e) {
        // this is fatal
        e.printStackTrace();

        System.exit(1);
    }

    this.canvas.setPreferredSize(new Dimension(0, 0));
    this.canvas.setMinimumSize(new Dimension(0, 0));

    //        canvas.setGL(new DebugGL(canvas.getGL()));
    final RenderParameters rp = getAllParams().getRenderParameters();

    this.anim = new FPSAnimator(this.canvas, (int) rp.getFpsTarget());

    // generate the terrain
    final RegenAction action = new RegenAction("Regenerate");

    action.actionPerformed(new ActionEvent(this, 1, "Regenerate"));
}

From source file:TreeUtil.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    int idx = cmd.indexOf('.');
    cmd = cmd.substring(++idx, cmd.length());
    fireActionEvent(new ActionEvent(this, MENU, cmd));
}

From source file:org.nekorp.workflow.desktop.view.AppMainWindow.java

/**
 * call this somewhere in your GUI construction
 *///from  w  w w .j  a v a2  s.  co m
private void setupKeyShortcut() {
    KeyStroke key1 = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK);
    actionMap.put(key1, new AbstractAction("guardar") {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (editorMonitor.hasChange()) {
                try {
                    aplication.guardaServicio();
                } catch (IllegalArgumentException ex) {
                    //no lo guardo.
                }
            }
        }
    });
    //        key1 = KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_DOWN_MASK);
    //        actionMap.put(key1, new AbstractAction("deshacer") {
    //            @Override
    //            public void actionPerformed(ActionEvent e) {
    //                if (editorMonitor.hasChange()) {
    //                    editorMonitor.undo();
    //                }
    //            }
    //        });
    //        key1 = KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_DOWN_MASK);
    //        actionMap.put(key1, new AbstractAction("rehacer") {
    //            @Override
    //            public void actionPerformed(ActionEvent e) {
    //                editorMonitor.redo();
    //            }
    //        });
    // add more actions..

    KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    kfm.addKeyEventDispatcher(new KeyEventDispatcher() {
        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {
            KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(e);
            if (actionMap.containsKey(keyStroke)) {
                final Action a = actionMap.get(keyStroke);
                final ActionEvent ae = new ActionEvent(e.getSource(), e.getID(), null);
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        a.actionPerformed(ae);
                    }
                });
                return true;
            }
            return false;
        }
    });
}

From source file:au.org.ala.delta.editor.ui.CharacterTree.java

public CharacterTree() {

    setToggleClickCount(0);//from w ww.  jav  a 2  s. c  om
    _characterListBehaviour = new CharacterListBehaviour();
    _stateListBehaviour = new StateListBehaviour();

    ToolTipManager.sharedInstance().registerComponent(this);

    addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent e) {
            if (_doubleProcessingMouseEvent) {
                return;
            }
            if (!isEditing()) {
                int selectedRow = getClosestRowForLocation(e.getX(), e.getY());

                if ((selectedRow >= 0) && (e.getClickCount() == 2) && SwingUtilities.isLeftMouseButton(e)) {
                    Action action = getActionMap().get(SELECTION_ACTION_KEY);
                    if (action != null) {
                        action.actionPerformed(new ActionEvent(this, -1, ""));
                    }
                }
            }
        }
    });

    addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {

            TreePath selection = e.getNewLeadSelectionPath();
            if (selection != null) {
                Object lastComponent = selection.getLastPathComponent();
                if (lastComponent instanceof DefaultMutableTreeNode) {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) lastComponent;

                    if (node.isLeaf()) {
                        CharacterTree.super.setTransferHandler(_stateTransferHandler);
                    } else {
                        CharacterTree.super.setTransferHandler(_characterTransferHandler);
                    }
                }
            }
        }
    });

    ActionMap actionMap = Application.getInstance().getContext().getActionMap(this);

    javax.swing.Action find = actionMap.get("find");
    if (find != null) {
        getActionMap().put("find", find);
    }

    javax.swing.Action findNext = actionMap.get("findNext");
    if (findNext != null) {
        getActionMap().put("findNext", findNext);
    }

    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.CTRL_MASK), SELECTION_ACTION_KEY);

}

From source file:GUI.WebBrowserPanel.java

private void fireActionEvent(Class thisClass, Integer action, String command) {
    Object listeners[] = m_listeners.getListenerList();
    for (int i = listeners.length - 1; i >= 0; i--) {
        if (listeners[i].getClass() == thisClass) {
            ((ActionListener) listeners[i]).actionPerformed(new ActionEvent(this, action, command));
            listeners = null;/*from  w ww.  j av a 2  s. com*/
            return;
        }
    }
    listeners = null;
}

From source file:eclserver.threads.EmergencyCallPush.java

@Override
protected void done() {
    // whether we retrieved anything or not
    // we're done, so set the progress indicator accordingly

    try {/* w  w  w  .  j  a v  a2s. c  om*/

        recipients = recListDao.getListEntries();
        ActionEvent callReload = new ActionEvent(new Object[] { "Reload Recs" }, 1, "RELOAD_RECS");
        recPanel.actionPerformed(callReload);
        recPanel.setRecipientsListEntries(recipients);

        String recCompleted = (String) get();

        System.out.println("Call Push THREAD: " + recCompleted);

        ecPanel.printToResults("\n\nCompleted Pushing Call content to Users.");

        setProgress(100);
        System.out.println("Thread wrapping up");

    } catch (ExecutionException ex) {
        System.out.println("\nContacts Push THREAD Thread Execution Exception: " + ex.getMessage());

    } catch (InterruptedException ex) {
        System.out.println("\nCall Push THREAD Thread Interrupted Exception: " + ex.getMessage());

    }
    if (recipients.isEmpty()) {
        ecPanel.printToResults("\nDidn't retrieve anything from file in DONE() thread.");
    }

}