Example usage for java.awt.event ActionEvent ACTION_PERFORMED

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

Introduction

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

Prototype

int ACTION_PERFORMED

To view the source code for java.awt.event ActionEvent ACTION_PERFORMED.

Click Source Link

Document

This event id indicates that a meaningful action occurred.

Usage

From source file:de.juwimm.cms.Main.java

private void showToolPanel(boolean withSelection, ActionEvent e) throws Exception {
    if (Constants.CMS_CLIENT_VIEW != Constants.CLIENT_VIEW_CONTENT) {
        panRibbon.setView(true);/*from ww  w  .  jav  a 2s . c om*/
        try {
            panTool = PanTool.getInstance();
            panTool.reload(withSelection, e.getSource());
        } catch (UserHasNoUnitsException ex) {
            JOptionPane.showMessageDialog(UIConstants.getMainFrame(), ex.getMessage(),
                    rb.getString("msgbox.title.loginFailed"), JOptionPane.ERROR_MESSAGE);
            ActionHub.fireActionPerformed(
                    new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Constants.ACTION_LOGOFF));
            return;
        } catch (NullPointerException npe) {
            panTool.setTreeToEmpty();
            JOptionPane.showMessageDialog(UIConstants.getMainFrame(), rb.getString("exception.SiteIsEmpty"),
                    rb.getString("dialog.title"), JOptionPane.ERROR_MESSAGE);
        }
        setCenterPanel(panTool);
    }
}

From source file:DragPictureDemo2.java

public void actionPerformed(ActionEvent e) {
    if (focusOwner == null)
        return;//from www  .  ja v  a  2s.  c  o m
    String action = (String) e.getActionCommand();
    Action a = focusOwner.getActionMap().get(action);
    if (a != null) {
        a.actionPerformed(new ActionEvent(focusOwner, ActionEvent.ACTION_PERFORMED, null));
    }
}

From source file:de.juwimm.cms.Main.java

public void actionPerformed(ActionEvent e) {
    String action = e.getActionCommand();
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    try {//w  w  w. jav  a  2 s.c  om
        if (action.equals(Constants.ACTION_EXIT)) {
            if (ActionHub.fireExitPerformed(new ExitEvent())) {
                comm.getDbHelper().shutdown();
                System.exit(0);
            }
        } else if (action.equals(Constants.ACTION_LOGIN)) {
            this.setLayout(new BorderLayout());
            Constants.CMS_CLIENT_VIEW = -1;
            setCenterPanel(PanInitView.getInstance());

            if (panStatusbar == null) {
                panStatusbar = new PanStatusbar();
                UIConstants.setStatusLine(panStatusbar);
                ActionHub.addActionListener(panStatusbar);
            }

            if (panRibbon == null) {
                panRibbon = new PanRibbon(comm);
                ActionHub.addActionListener(panRibbon);
            }
            this.getContentPane().add(panRibbon, BorderLayout.NORTH);
            ActionHub.fireActionPerformed(
                    new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Constants.ACTION_VIEW_EDITOR));

            //      this.getJMenuBar().setVisible(true);
            //      this.getContentPane().add(panToolbar, BorderLayout.NORTH);
            this.getContentPane().add(panStatusbar, BorderLayout.SOUTH);

            this.getRootPane().setDoubleBuffered(true);
            this.getRootPane().validate();
            this.getRootPane().repaint();
        } else if (action.equals(Constants.ACTION_LOGOFF)) {
            if (ActionHub.fireExitPerformed(new ExitEvent())) {
                comm.setLoggedIn(false);
                Application.initializeContext();
                panLogin = new PanLogin();
                panRoot = null;
                panAdmin = null;
                panRibbon = null;
                this.getContentPane().removeAll();
                //this.getJMenuBar().setVisible(false);
                comm.getDbHelper().autoEmptyCache();
                PanContentView.getInstance().unloadAll();
                setCenterPanel(panLogin);
                Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_LOGIN;
                this.validate();
                this.getContentPane().validate();
                this.getContentPane().repaint();
                this.repaint();
                panLogin.init();
            }
        } else if (action.equals(Constants.ACTION_VIEW_EDITOR)) {
            showToolPanel(false, e);
            panTool = PanTool.getInstance();
            Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_CONTENT;
        } else if (action.equals(Constants.ACTION_VIEW_EDITOR_WITH_SELECTION)) {
            showToolPanel(true, e);
            panTool = PanTool.getInstance();
            Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_CONTENT;
        } else if (action.equals(Constants.ACTION_VIEW_ADMIN) || action.equals(Constants.ACTION_VIEW_ROOT)) {
            Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_ADMIN;
            showAdminPanel();
            panStatusbar.setCountVisible(false);
        } else if (action.equals(Constants.ACTION_CHANGE_PASSWORD)) {
            showChangePasswordDialog();
        } else if (action.equals(Constants.ACTION_SHOW_TASK)) {
            showTaskPanel();
            panStatusbar.setCountVisible(false);
            Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_TASK;
        } else if (action.equals(Constants.ACTION_SHOW_CONTENT)) {
            Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_CONTENT;
        }
    } catch (Exception exe) {
        log.error("Error in actionPerformed", exe);
    } finally {
        this.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:com.mightypocket.ashot.Mediator.java

void executeAction(String actionName) {
    application.getContext().getActionManager().getActionMap(Mediator.class, this).get(actionName)
            .actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null));
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * Sets the font family and size//from  ww w  .  j a  v  a2  s  . c o m
 * @param family the family name
 * @param size the size
 */
public void setFontFamilyAndSize(String family, int size) {
    // Family
    ActionEvent evt = new ActionEvent(editorPane, ActionEvent.ACTION_PERFORMED, family);

    Action action = new StyledEditorKit.FontFamilyAction(family, family);
    action.actionPerformed(evt);

    // Size
    evt = new ActionEvent(editorPane, ActionEvent.ACTION_PERFORMED, Integer.toString(size));
    action = new StyledEditorKit.FontSizeAction(Integer.toString(size), size);
    action.actionPerformed(evt);
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * Sets the font color/*from   w ww.ja v a 2 s.c o m*/
 * @param color the color
 */
public void setFontColor(Color color) {
    ActionEvent evt = new ActionEvent(editorPane, ActionEvent.ACTION_PERFORMED, "");

    Action action = new HTMLEditorKit.ForegroundAction(Integer.toString(color.getRGB()), color);

    action.actionPerformed(evt);
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * Sets the given style constant./*ww  w .  j ava 2  s .  co  m*/
 *
 * @param action the action
 * @param styleConstant the style constant
 */
private void setStyleConstant(Action action, Object styleConstant) {
    ActionEvent event = new ActionEvent(editorPane, ActionEvent.ACTION_PERFORMED, styleConstant.toString());

    action.actionPerformed(event);
}

From source file:com.servoy.j2db.util.Utils.java

public static int streamCopy(InputStream is, OutputStream os, ActionListener l, int actionSize)
        throws IOException {
    int actionBlock = actionSize;

    if (is == null || os == null)
        return 0;
    int bufferSize = 128;
    byte[] buffer = new byte[bufferSize];
    int length = 0;
    int totalLength = 0;
    while ((length = is.read(buffer)) >= 0) {
        os.write(buffer, 0, length);//from   www .j a  v a  2 s.  c  om
        totalLength += length;

        if (actionSize > 0 && totalLength > actionBlock) {
            actionBlock += actionSize;
            if (l != null)
                l.actionPerformed(new ActionEvent("streamCopy", ActionEvent.ACTION_PERFORMED, "streamCopy")); //$NON-NLS-1$ //$NON-NLS-2$
        }
    }
    return totalLength;
}

From source file:com.googlecode.vfsjfilechooser2.VFSJFileChooser.java

/**
 * Notifies all listeners that have registered interest for
 * notification on this event type. The event instance
 * is lazily created using the <code>command</code> parameter.
 *
 * @see EventListenerList// w  w  w.  j a va  2  s.co  m
 */
protected void fireActionPerformed(String command) {
    // Guaranteed to return a non-null array
    Object[] listeners = listenerList.getListenerList();
    long mostRecentEventTime = EventQueue.getMostRecentEventTime();
    int modifiers = 0;
    AWTEvent currentEvent = EventQueue.getCurrentEvent();

    if (currentEvent instanceof InputEvent) {
        modifiers = ((InputEvent) currentEvent).getModifiers();
    } else if (currentEvent instanceof ActionEvent) {
        modifiers = ((ActionEvent) currentEvent).getModifiers();
    }

    ActionEvent e = null;

    // Process the listeners last to first, notifying
    // those that are interested in this event
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == ActionListener.class) {
            // Lazily create the event:
            if (e == null) {
                e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, command, mostRecentEventTime,
                        modifiers);
            }

            ((ActionListener) listeners[i + 1]).actionPerformed(e);
        }
    }
}

From source file:com.projity.contrib.calendar.JXXMonthView.java

/**
 * Fires an ActionEvent to all listeners.
 *//*ww w .  ja va  2s. co  m*/
protected void fireActionPerformed() {
    Object[] listeners = listenerList.getListenerList();
    ActionEvent e = null;
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == ActionListener.class) {
            if (e == null) {
                e = new ActionEvent(JXXMonthView.this, ActionEvent.ACTION_PERFORMED, _actionCommand);
            }
            ((ActionListener) listeners[i + 1]).actionPerformed(e);
        }
    }
}