本文整理汇总了Java中java.awt.ActiveEvent类的典型用法代码示例。如果您正苦于以下问题:Java ActiveEvent类的具体用法?Java ActiveEvent怎么用?Java ActiveEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActiveEvent类属于java.awt包,在下文中一共展示了ActiveEvent类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchNextGuiEvent
import java.awt.ActiveEvent; //导入依赖的package包/类
/**
* Processes the next GUI event.
*/
public void dispatchNextGuiEvent() throws InterruptedException {
EventQueue queue = awtEventQueue;
if (queue == null) {
queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
awtEventQueue = queue;
}
AWTEvent event = queue.getNextEvent();
if (event instanceof ActiveEvent) {
((ActiveEvent)event).dispatch();
} else {
Object source = event.getSource();
if (source instanceof Component) {
Component comp = (Component)source;
comp.dispatchEvent(event);
} else if (source instanceof MenuComponent) {
((MenuComponent)source).dispatchEvent(event);
}
}
}
示例2: setVisible
import java.awt.ActiveEvent; //导入依赖的package包/类
@Override
public void setVisible(boolean visible) {
boolean blockParent = (visible && modal);
owner.setEnabled(!blockParent);
owner.setFocusableWindowState(!blockParent);
super.setVisible(visible);
if (blockParent) {
owner.addWindowListener(parentWindowListener);
try {
if (SwingUtilities.isEventDispatchThread()) {
EventQueue theQueue = getToolkit().getSystemEventQueue();
while (isVisible()) {
AWTEvent event = theQueue.getNextEvent();
Object src = event.getSource();
if (event instanceof ActiveEvent) {
((ActiveEvent) event).dispatch();
} else if (src instanceof Component) {
((Component) src).dispatchEvent(event);
}
}
} else {
synchronized (getTreeLock()) {
while (isVisible()) {
try {
getTreeLock().wait();
} catch (InterruptedException e) {
break;
}
}
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
} else {
owner.removeWindowListener(parentWindowListener);
// added 2 lines
owner.setEnabled(true);
owner.setFocusableWindowState(true);
}
}
示例3: dispatchEvent
import java.awt.ActiveEvent; //导入依赖的package包/类
public void dispatchEvent( AWTEvent event )
{
Object src = event.getSource();
if( event instanceof ActiveEvent )
{
((ActiveEvent)event).dispatch();
}
else if( src instanceof Component )
{
((Component)src).dispatchEvent( event );
}
else if( src instanceof MenuComponent )
{
((MenuComponent)src).dispatchEvent( event );
}
}
示例4: showModal
import java.awt.ActiveEvent; //导入依赖的package包/类
private void showModal() {
EventQueue theQueue = getToolkit().getSystemEventQueue();
while (isVisible()) {
AWTEvent event = null;
try {
event = theQueue.getNextEvent();
} catch (InterruptedException x) {
LOG.warning(x.getLocalizedMessage());
continue;
}
Object source = event.getSource();
if (event instanceof MouseEvent) {
MouseEvent e = (MouseEvent) event;
MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this);
if (!this.contains(m.getPoint()) && e.getID() != MouseEvent.MOUSE_DRAGGED) {
continue;
}
}
if (event instanceof ActiveEvent) {
((ActiveEvent) event).dispatch();
} else if (source instanceof Component) {
((Component) source).dispatchEvent(event);
} else if (source instanceof MenuComponent) {
((MenuComponent) source).dispatchEvent(event);
} else {
LOG.warning("Not dispatched: " + event);
}
}
}
示例5: lock
import java.awt.ActiveEvent; //导入依赖的package包/类
public void lock() {
lockCount++;
setCursorRecursive(this, Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
EventQueue theQueue = getToolkit().getSystemEventQueue();
while (lockCount > 0) {
AWTEvent event = null;
try {
event = theQueue.getNextEvent();
} catch (InterruptedException x) {
LOG.warning(x.getLocalizedMessage());
continue;
}
Object source = event.getSource();
if (event instanceof MouseEvent) {
continue;
}
if (event instanceof ActiveEvent) {
((ActiveEvent) event).dispatch();
} else if (source instanceof Component) {
((Component) source).dispatchEvent(event);
} else if (source instanceof MenuComponent) {
((MenuComponent) source).dispatchEvent(event);
} else {
LOG.warning("Not dispatched: " + event);
}
}
setCursorRecursive(this, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
示例6: startModal
import java.awt.ActiveEvent; //导入依赖的package包/类
/**
* This helper method makes the JInternalFrame wait until it is notified by
* an InternalFrameClosing event. This method also adds the given
* JOptionPane to the JInternalFrame and sizes it according to the
* JInternalFrame's preferred size.
*
* @param f The JInternalFrame to make modal.
*/
private static void startModal(JInternalFrame f)
{
// We need to add an additional glasspane-like component directly
// below the frame, which intercepts all mouse events that are not
// directed at the frame itself.
JPanel modalInterceptor = new JPanel();
modalInterceptor.setOpaque(false);
JLayeredPane lp = JLayeredPane.getLayeredPaneAbove(f);
lp.setLayer(modalInterceptor, JLayeredPane.MODAL_LAYER.intValue());
modalInterceptor.setBounds(0, 0, lp.getWidth(), lp.getHeight());
modalInterceptor.addMouseListener(new MouseAdapter(){});
modalInterceptor.addMouseMotionListener(new MouseMotionAdapter(){});
lp.add(modalInterceptor);
f.toFront();
// We need to explicitly dispatch events when we are blocking the event
// dispatch thread.
EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
try
{
while (! f.isClosed())
{
if (EventQueue.isDispatchThread())
{
// The getNextEventMethod() issues wait() when no
// event is available, so we don't need do explicitly wait().
AWTEvent ev = queue.getNextEvent();
// This mimics EventQueue.dispatchEvent(). We can't use
// EventQueue.dispatchEvent() directly, because it is
// protected, unfortunately.
if (ev instanceof ActiveEvent)
((ActiveEvent) ev).dispatch();
else if (ev.getSource() instanceof Component)
((Component) ev.getSource()).dispatchEvent(ev);
else if (ev.getSource() instanceof MenuComponent)
((MenuComponent) ev.getSource()).dispatchEvent(ev);
// Other events are ignored as per spec in
// EventQueue.dispatchEvent
}
else
{
// Give other threads a chance to become active.
Thread.yield();
}
}
}
catch (InterruptedException ex)
{
// If we get interrupted, then leave the modal state.
}
finally
{
// Clean up the modal interceptor.
lp.remove(modalInterceptor);
// Remove the internal frame from its parent, so it is no longer
// lurking around and clogging memory.
Container parent = f.getParent();
if (parent != null)
parent.remove(f);
}
}
示例7: dispatchEvent
import java.awt.ActiveEvent; //导入依赖的package包/类
/**
* Dispatches an event. The manner in which the event is
* dispatched depends upon the type of the event and the
* type of the event's source object:
* <p> </p>
* <table border=1 summary="Event types, source types, and dispatch methods">
* <tr>
* <th>Event Type</th>
* <th>Source Type</th>
* <th>Dispatched To</th>
* </tr>
* <tr>
* <td>ActiveEvent</td>
* <td>Any</td>
* <td>event.dispatch()</td>
* </tr>
* <tr>
* <td>Other</td>
* <td>Component</td>
* <td>source.dispatchEvent(AWTEvent)</td>
* </tr>
* <tr>
* <td>Other</td>
* <td>MenuComponent</td>
* <td>source.dispatchEvent(AWTEvent)</td>
* </tr>
* <tr>
* <td>Other</td>
* <td>Other</td>
* <td>No action (ignored)</td>
* </tr>
* </table>
* <p> </p>
* @param event an instance of <code>java.awt.AWTEvent</code>,
* or a subclass of it
* @throws NullPointerException if <code>event</code> is <code>null</code>
* @since 1.2
*/
protected void dispatchEvent(AWTEvent event) {
event.isPosted = true;
Object src = event.getSource();
if (event instanceof ActiveEvent) {
// This could become the sole method of dispatching in time.
setCurrentEventAndMostRecentTimeImpl(event);
((ActiveEvent)event).dispatch();
} else if (src instanceof Component) {
((Component)src).dispatchEvent(event);
event.dispatched();
} else if (src instanceof MenuComponent) {
((MenuComponent)src).dispatchEvent(event);
} else if (src instanceof TrayIcon) {
((TrayIcon)src).dispatchEvent(event);
} else if (src instanceof AWTAutoShutdown) {
if (noEvents()) {
dispatchThread.stopDispatching();
}
} else {
System.err.println("unable to dispatch event: " + event);
}
}
示例8: getResponse
import java.awt.ActiveEvent; //导入依赖的package包/类
/**
* Returns the <code>response</code> when set by
* <code>setResponse(Object response)</code>.
* Waits the thread until then.
*
* @return The object as set by {@link #setResponse}.
*/
public synchronized T getResponse() {
// Wait the thread until 'response' is available. Notice that
// we have to process the events manually if the current
// thread is the Event Dispatch Thread (EDT).
try {
if (SwingUtilities.isEventDispatchThread()) {
EventQueue theQueue = getToolkit().getSystemEventQueue();
while (!responseGiven) {
// This is essentially the body of EventDispatchThread
AWTEvent event = theQueue.getNextEvent();
Object src = event.getSource();
try {
// We cannot call theQueue.dispatchEvent, so I
// pasted its body here:
if (event instanceof ActiveEvent) {
((ActiveEvent) event).dispatch();
} else if (src instanceof Component) {
((Component) src).dispatchEvent(event);
} else if (src instanceof MenuComponent) {
((MenuComponent) src).dispatchEvent(event);
} else {
logger.warning("unable to dispatch event: "
+ event);
}
} finally {
continue;
}
}
} else {
while (!responseGiven) {
wait();
}
}
} catch (InterruptedException e) {}
T tempResponse = response;
response = null;
responseGiven = false;
return tempResponse;
}