use of java.awt.AWTEvent in project JMRI by JMRI.
the class Apps3 method splash.
protected static void splash(boolean show, boolean debug) {
if (debugListener == null && debug) {
// set a global listener for debug options
debugFired = false;
debugListener = new AWTEventListener() {
@Override
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "debugmsg write is semi-global")
public void eventDispatched(AWTEvent e) {
if (!debugFired) {
/*We set the debugmsg flag on the first instance of the user pressing any button
and the if the debugFired hasn't been set, this allows us to ensure that we don't
miss the user pressing F8, while we are checking*/
debugmsg = true;
if (e.getID() == KeyEvent.KEY_PRESSED && e instanceof KeyEvent && ((KeyEvent) e).getKeyCode() == 119) {
startupDebug();
} else {
debugmsg = false;
}
}
}
};
Toolkit.getDefaultToolkit().addAWTEventListener(debugListener, AWTEvent.KEY_EVENT_MASK);
}
// bring up splash window for startup
if (sp == null) {
sp = new SplashWindow((debug) ? splashDebugMsg() : null);
}
sp.setVisible(show);
if (!show) {
sp.dispose();
Toolkit.getDefaultToolkit().removeAWTEventListener(debugListener);
debugListener = null;
sp = null;
}
}
use of java.awt.AWTEvent in project sling by apache.
the class RequestAnalyzerWebConsole method dispose.
void dispose() {
if (this.frame != null) {
MainFrame frame = this.frame;
this.frame = null;
AWTEvent e = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e);
}
}
use of java.awt.AWTEvent in project jdk8u_jdk by JetBrains.
the class JFileChooser method fireActionPerformed.
/**
* 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
*/
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;
// 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);
}
}
}
use of java.awt.AWTEvent in project ffx by mjschnie.
the class GraphicsEvents method processStimulus.
// Most of the logic for mouse interaction with the Scenegraph is here.
/**
* {@inheritDoc}
*/
public void processStimulus(Enumeration criteria) {
viewOrbitBehavior.setEnable(false);
AWTEvent[] awtEvents = null;
while (criteria.hasMoreElements()) {
WakeupCriterion wakeup = (WakeupCriterion) criteria.nextElement();
if (wakeup instanceof WakeupOnAWTEvent) {
awtEvents = ((WakeupOnAWTEvent) wakeup).getAWTEvent();
if (awtEvents == null) {
continue;
}
for (int i = 0; i < awtEvents.length; i++) {
MouseEvent mouseEvent = null;
if (awtEvents[i] instanceof MouseEvent) {
mouseEvent = (MouseEvent) awtEvents[i];
processMouseEvent(mouseEvent);
} else {
continue;
}
if (!axisSelected) {
// Wake Up System Translate Behavior
if (rightButton && buttonPress) {
systemTranslate.setMouseButton(MouseEvent.BUTTON3_DOWN_MASK);
if (systemTranslate()) {
wakeupOn(postCriterion);
return;
}
}
// Wake Up Left Button Mode
if (leftButton && buttonPress) {
LeftButtonMode leftButtonMode = graphics3D.getLeftButtonMode();
switch(leftButtonMode) {
case ROTATE:
if (systemRotate()) {
wakeupOn(postCriterion);
return;
}
break;
case TRANSLATE:
systemTranslate.setMouseButton(MouseEvent.BUTTON1_DOWN_MASK);
if (systemTranslate()) {
wakeupOn(postCriterion);
return;
}
break;
case ZOOM:
globalZoom.setMouseButton(MouseEvent.BUTTON1_DOWN_MASK);
if (globalZoom()) {
wakeupOn(postCriterion);
return;
}
}
}
// Wake up Global Zoom Behavior
if (middleButton && buttonPress) {
globalZoom.setMouseButton(MouseEvent.BUTTON2_DOWN_MASK);
if (globalZoom()) {
wakeupOn(postCriterion);
return;
}
}
} else {
viewOrbitBehavior.setEnable(true);
wakeupOn(mouseCriterion);
return;
}
}
}
}
wakeupOn(mouseCriterion);
}
use of java.awt.AWTEvent in project ffx by mjschnie.
the class MouseSelection method processStimulus.
/**
* {@inheritDoc}
*/
public void processStimulus(Enumeration criteria) {
WakeupCriterion wakeup;
AWTEvent[] event;
int id;
while (criteria.hasMoreElements()) {
wakeup = (WakeupCriterion) criteria.nextElement();
if (wakeup instanceof WakeupOnAWTEvent) {
event = ((WakeupOnAWTEvent) wakeup).getAWTEvent();
for (int i = 0; i < event.length; i++) {
processMouseEvent((MouseEvent) event[i]);
if (((buttonPress) && ((flags & MANUAL_WAKEUP) == 0)) || ((wakeUp) && ((flags & MANUAL_WAKEUP) != 0))) {
id = event[i].getID();
if ((id == MouseEvent.MOUSE_DRAGGED)) {
if (!reset) {
transformChanged(currXform);
if (callback != null) {
callback.transformChanged(MouseBehaviorCallback.SELECTION, currXform);
}
} else {
reset = false;
}
x_last = ((MouseEvent) event[i]).getX();
y_last = ((MouseEvent) event[i]).getY();
}
if (id == MouseEvent.MOUSE_PRESSED) {
x_last = ((MouseEvent) event[i]).getX();
y_last = ((MouseEvent) event[i]).getY();
}
}
}
}
}
wakeupOn(mouseCriterion);
}
Aggregations