Java Code Examples for java.awt.event.ActionEvent

The following are top voted examples for showing how to use java.awt.event.ActionEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.

Example 1
Project: funCKit   File: ChangeColorActionListener.java View source code 7 votes vote down vote up
@Override
public void actionPerformed(ActionEvent event) {
    settingKey = event.getActionCommand();
    Settings settings = controller.getSessionModel().getSettings();
    Color oldColor = settings.get(settingKey, Color.class);

    if (oldColor == null) {
        chooserPane = new JColorChooser();
    } else {
        chooserPane = new JColorChooser(oldColor);
    }

    JDialog colorDialog = JColorChooser.createDialog(view.getMainRootPane(), settingKey, true,
            chooserPane, new OkListener(), null);
    colorDialog.setVisible(true);
}
 
Example 2
Project: JAME   File: RenderedPalettePanel.java View source code 6 votes vote down vote up
/**
 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 */
public void actionPerformed(final ActionEvent e) {
	final RenderedPaletteParamModel paramModel = getRenderedPaletteParamModel(RenderedPalettePanel.PALETTE_PARAM_MODEL);
	final SingleSelectionModel selectionModel = getSingleSelectionModel(RenderedPalettePanel.PARAM_SELECTION_MODEL);
	final JComboBox comboBox = (JComboBox) e.getSource();
	if (comboBox.getModel().getSelectedItem() != null) {
		removeRenderedPaletteParamListener();
		removeSelectionListener();
		selectionModel.setSelectedIndex(comboBox.getSelectedIndex());
		paramModel.setPaletteParam((RenderedPaletteParam) comboBox.getModel().getSelectedItem(), false);
		addRenderedPaletteParamListener();
		addSelectionListener();
	}
}
 
Example 3
Project: UnicentaPOS_AD   File: AuxiliarFilter.java View source code 6 votes vote down vote up
protected void fireSelectedProduct() {
    EventListener[] l = listeners.getListeners(ActionListener.class);
    ActionEvent e = null;
    for (int i = 0; i < l.length; i++) {
        if (e == null) {
            e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "SELECTED");
        }
        ((ActionListener) l[i]).actionPerformed(e);	       
    }
}
 
Example 4
Project: fiji   File: IntField.java View source code 6 votes vote down vote up
/** Hand on an ActionEvent to listeners only if a new and valid
integer has been entered. */
protected void processActionEvent(ActionEvent e) {
	int tempValue;
	if (e.getSource() == this) {
		try {
			tempValue = Integer.parseInt(getText());
		} catch (NumberFormatException ex) {
			setText(Integer.toString(value));
			return;
		}
		if (tempValue >= minValue && tempValue <= maxValue && tempValue != value) {
			value = tempValue;
			super.processActionEvent(new ActionEvent(this, e.getID(), actionCommand, e.getModifiers()));
		}
		setText(Integer.toString(value));
	}
}
 
Example 5
Project: OSM2World   File: ReloadOSMAction.java View source code 6 votes vote down vote up
public ReloadOSMAction(ViewerFrame viewerFrame, Data data,
		RenderOptions renderOptions, File configFile) {
	
	super("Reload OSM file");
	putValue(SHORT_DESCRIPTION, "Reloads the most recently opened OSM file" +
			" and the configuration file");
	putValue(MNEMONIC_KEY, KeyEvent.VK_R);
	putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(
			KeyEvent.VK_R, ActionEvent.CTRL_MASK));
	
	this.viewerFrame = viewerFrame;
	this.data = data;
	this.renderOptions = renderOptions;
	this.configFile = configFile;
	
	this.setEnabled(false);
	
	data.addObserver(this);
	
}
 
Example 6
Project: fiji   File: AbstractInterpreter.java View source code 6 votes vote down vote up
void cycle(ActionEvent ae) {
	if (null == ae) {
		// first time
		set();
		return;
	}

	/*
	p("##\nlen_prev: " + len_prev);
	p("i : " + i);
	p("prompt.getText(): " + prompt.getText());
	p("prompt.getText().length(): " + prompt.getText().length());
	p("istart: " + istart + "\n##");
	*/

	int plen = prompt.getText().length();
	String stub = extractWordStub(prompt.getText(), this.istart + len_prev > plen ? plen : this.istart + len_prev); // may be null
	if (this.stub.equals(stub) || al.get(i).equals(stub)) {
		// ok
	} else {
		// can't expand, remake
		last_tab_expand = null;
		expandName(prompt.getText(), ae);
		return;
	}

	// check preconditions
	if (0 == al.size()) {
		p("No elems to expand to");
		return;
	}

	// ok set prompt to next
	i += ( 0 != (ae.getModifiers() & ActionEvent.SHIFT_MASK) ? -1 : 1);
	if (al.size() == i) i = 0;
	if (-1 == i) i = al.size() -1;
	set();
}
 
Example 7
Project: CheS-Mapper   File: Actions.java View source code 6 votes vote down vote up
public static void main(String args[])
{

	KeyStroke keystroke = KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.ALT_MASK);
	System.out.println(KeyEvent.getKeyModifiersText(keystroke.getModifiers()));
	System.out.println(Character.toChars(keystroke.getKeyCode())[0]);

	//showAboutDialog();
}
 
Example 8
Project: jeboorker   File: JProgressButton.java View source code 6 votes vote down vote up
protected void internalFireActionPerformed(ActionEvent event) {
	// Guaranteed to return a non-null array
	Object[] listeners = listenerList.getListenerList();
	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) {
				String actionCommand = event.getActionCommand();
				if (actionCommand == null) {
					actionCommand = getActionCommand();
				}
				e = new ActionEvent(JProgressButton.this, ActionEvent.ACTION_PERFORMED, actionCommand, event.getWhen(), event.getModifiers());
			}
			if (((ActionListener) listeners[i + 1]) instanceof ProgressAction) {
				((ProgressAction) listeners[i + 1]).wrappedAction.actionPerformed(e);
			} else {
				((ActionListener) listeners[i + 1]).actionPerformed(e);
			}
		}
	}
}
 
Example 9
Project: rapidminer-vega   File: ResourceActionTransmitter.java View source code 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
	if (eventSource != null) {
		e.setSource(eventSource);
	}
	action.actionPerformed(e);
}
 
Example 10
Project: fiji   File: IntField.java View source code 6 votes vote down vote up
/** Sets the value of the field to newValue. Sends and ActionEvent,
*	if sendEvent is true.
*/
public void setValue(int newValue, boolean sendEvent) {
	if (newValue >= minValue && newValue <= maxValue) {
		if (newValue != value) {
			if (sendEvent) {					
				setText(Integer.toString(newValue));
				processEvent(new ActionEvent(this, ActionEvent.ACTION_FIRST, actionCommand));
			} else {
				value = newValue;
				setText(Integer.toString(newValue));
			}
		}
	} else {
		throw new IllegalArgumentException("value out of range: "+newValue);
	}
}
 
Example 11
Project: Desktop   File: IconSelectionPopupDialog.java View source code 6 votes vote down vote up
/**
 * Transfer shift masks from InputEvent to ActionEvent. But, why don't they
 * use the same constants???? Java miracle.
 */
public int getModifiers() {
	int m = mModifiers;
	if ((mModifiers & (ActionEvent.SHIFT_MASK | InputEvent.SHIFT_DOWN_MASK)) != 0) {
		m |= ActionEvent.SHIFT_MASK;
	}
	if ((mModifiers & (ActionEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK)) != 0) {
		m |= ActionEvent.CTRL_MASK;
	}
	if ((mModifiers & (ActionEvent.META_MASK | InputEvent.META_DOWN_MASK)) != 0) {
		m |= ActionEvent.META_MASK;
	}
	if ((mModifiers & (ActionEvent.ALT_MASK | InputEvent.ALT_DOWN_MASK)) != 0) {
		m |= ActionEvent.ALT_MASK;
	}
	return m;
}
 
Example 12
Project: property-db   File: EventDispatchThread.java View source code 5 votes vote down vote up
public FilterAction acceptEvent(AWTEvent event) {
    if (modalComponent != null) {
        int eventID = event.getID();
        boolean mouseEvent = (eventID >= MouseEvent.MOUSE_FIRST) &&
                             (eventID <= MouseEvent.MOUSE_LAST);
        boolean actionEvent = (eventID >= ActionEvent.ACTION_FIRST) &&
                              (eventID <= ActionEvent.ACTION_LAST);
        boolean windowClosingEvent = (eventID == WindowEvent.WINDOW_CLOSING);
        /*
         * filter out MouseEvent and ActionEvent that's outside
         * the modalComponent hierarchy.
         * KeyEvent is handled by using enqueueKeyEvent
         * in Dialog.show
         */
        if (Component.isInstanceOf(modalComponent, "javax.swing.JInternalFrame")) {
            /*
             * Modal internal frames are handled separately. If event is
             * for some component from another heavyweight than modalComp,
             * it is accepted. If heavyweight is the same - we still accept
             * event and perform further filtering in LightweightDispatcher
             */
            return windowClosingEvent ? FilterAction.REJECT : FilterAction.ACCEPT;
        }
        if (mouseEvent || actionEvent || windowClosingEvent) {
            Object o = event.getSource();
            if (o instanceof sun.awt.ModalExclude) {
                // Exclude this object from modality and
                // continue to pump it's events.
                return FilterAction.ACCEPT;
            } else if (o instanceof Component) {
                Component c = (Component) o;
                // 5.0u3 modal exclusion
                boolean modalExcluded = false;
                if (modalComponent instanceof Container) {
                    while (c != modalComponent && c != null) {
                        if ((c instanceof Window) &&
                            (sun.awt.SunToolkit.isModalExcluded((Window)c))) {
                            // Exclude this window and all its children from
                            //  modality and continue to pump it's events.
                            modalExcluded = true;
                            break;
                        }
                        c = c.getParent();
                    }
                }
                if (!modalExcluded && (c != modalComponent)) {
                    return FilterAction.REJECT;
                }
            }
        }
    }
    return FilterAction.ACCEPT;
}