当前位置: 首页>>代码示例>>Java>>正文


Java AWTEvent类代码示例

本文整理汇总了Java中java.awt.AWTEvent的典型用法代码示例。如果您正苦于以下问题:Java AWTEvent类的具体用法?Java AWTEvent怎么用?Java AWTEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AWTEvent类属于java.awt包,在下文中一共展示了AWTEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processEvent

import java.awt.AWTEvent; //导入依赖的package包/类
@Override
protected void processEvent(AWTEvent evt) {
    int id = evt.getID();
    if (id != KeyEvent.KEY_TYPED) {
        super.processEvent(evt);
        return;
    }

    KeyEvent kevt = (KeyEvent) evt;
    char c = kevt.getKeyChar();

    // Digits, backspace, and delete are okay
    // Note that the minus sign is not allowed (neither is decimal)
    if (Character.isDigit(c) || (c == '\b') || (c == '\u007f')) {
        super.processEvent(evt);
        return;
    }

    Toolkit.getDefaultToolkit().beep();
    kevt.consume();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:DitherTest.java

示例2: eventDispatched

import java.awt.AWTEvent; //导入依赖的package包/类
public void eventDispatched(java.awt.AWTEvent aWTEvent) {
    if (aWTEvent instanceof MouseEvent) {
        MouseEvent mv = (MouseEvent)aWTEvent;
        if (mv.getID() == MouseEvent.MOUSE_CLICKED && mv.getClickCount() > 0) {
            //#118828
            if (! (aWTEvent.getSource() instanceof Component)) {
                removePopup();
                return;
            }
            
            Component comp = (Component)aWTEvent.getSource();
            Container par1 = SwingUtilities.getAncestorNamed(POPUP_NAME, comp); //NOI18N
            Container par2 = SwingUtilities.getAncestorNamed(SUB_POPUP_NAME, comp); //NOI18N
            // Container barpar = SwingUtilities.getAncestorOfClass(PopupUtil.class, comp);
            // if (par == null && barpar == null) {
            if ( par1 == null && par2 == null ) {
                removePopup();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:HintsUI.java

示例3: dispatchEvent

import java.awt.AWTEvent; //导入依赖的package包/类
/**
 * Dispatches {@code AWTEvent} to component passed in constructor. If
 * {@code (getDispatchingModel & JemmyProperties.QUEUE_MODEL_MASK) == 0}
 * dispatched event directly, otherwise uses
 * {@code javax.swing.SwingUtilities.invokeAndWait(Runnable)}<BR>
 *
 * @param event AWTEvent instance to be dispatched.
 * @throws ComponentIsNotVisibleException
 * @throws ComponentIsNotFocusedException
 */
public void dispatchEvent(final AWTEvent event) {
    // run in dispatch thread
    String eventToString = queueTool.invokeSmoothly(
            new QueueTool.QueueAction<String>("event.toString()") {
        @Override
        public String launch() {
            return event.toString();
        }
    }
    );
    output.printLine("Dispatch event " + eventToString);
    output.printGolden("Dispatch event " + event.getClass().toString());
    Dispatcher<Void> disp = new Dispatcher<>(event);
    queueTool.invokeAndWait(disp);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:EventDispatcher.java

示例4: waitEvent

import java.awt.AWTEvent; //导入依赖的package包/类
private AWTEvent waitEvent(long eventMask, long waitTime, TestOut waiterOutput) {
    EventWaiter waiter = new EventWaiter(eventMask);
    waiter.setTimeouts(timeouts.cloneThis());
    waiter.setOutput(waiterOutput);
    waiter.getTimeouts().
            setTimeout("Waiter.WaitingTime",
                    waitTime);
    waiter.getTimeouts().
            setTimeout("Waiter.TimeDelta",
                    timeouts.getTimeout("EventTool.EventCheckingDelta"));
    try {
        return waiter.waitAction(null);
    } catch (InterruptedException e) {
        output.printStackTrace(e);
        return null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:EventTool.java

示例5: eventDispatched

import java.awt.AWTEvent; //导入依赖的package包/类
public @Override void eventDispatched(java.awt.AWTEvent aWTEvent) {
    if (aWTEvent instanceof MouseEvent) {
        MouseEvent mv = (MouseEvent)aWTEvent;
        if (mv.getClickCount() > 0) {
            //#118828
            if (! (aWTEvent.getSource() instanceof Component)) {
                return;
            }
            Component comp = (Component)aWTEvent.getSource();
            Container par = SwingUtilities.getAncestorNamed("progresspopup", comp); //NOI18N
            Container barpar = SwingUtilities.getAncestorOfClass(StatusLineComponent.class, comp);
            if (par == null && barpar == null) {
                hidePopup();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:StatusLineComponent.java

示例6: show

import java.awt.AWTEvent; //导入依赖的package包/类
public void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel(master.getTextComponent());

    Window w = SwingUtilities.windowForComponent(master.getTextComponent());
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y - 1);  // slight visual adjustment
    contentWindow.setVisible(true);

    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:TooltipWindow.java

示例7: doSelect

import java.awt.AWTEvent; //导入依赖的package包/类
private void doSelect(JComponent owner) {
    invokingComponent = owner;
    invokingComponent.addMouseListener(this);
    invokingComponent.addMouseMotionListener(this);
    pTable.addMouseListener(this);
    pTable.addMouseMotionListener(this);
    pTable.getSelectionModel().addListSelectionListener( this );

    displayer.getModel().addComplexListDataListener( this );

    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);

    popup = new JPopupMenu();
    popup.setBorderPainted( false );
    popup.setBorder( BorderFactory.createEmptyBorder() );
    popup.add( pTable );
    popup.pack();
    int locationX = x - (int) pTable.getPreferredSize().getWidth();
    int locationY = y + 1;
    popup.setLocation( locationX, locationY );
    popup.setInvoker( invokingComponent );
    popup.addPopupMenuListener( this );
    popup.setVisible( true );
    shown = true;
    invocationTime = System.currentTimeMillis();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ButtonPopupSwitcher.java

示例8: eventDispatched

import java.awt.AWTEvent; //导入依赖的package包/类
public void eventDispatched(java.awt.AWTEvent aWTEvent) {
    if (aWTEvent instanceof MouseEvent) {
        MouseEvent mv = (MouseEvent)aWTEvent;
        if (mv.getID() == MouseEvent.MOUSE_CLICKED && mv.getClickCount() > 0) {
            //#118828
            if (! (aWTEvent.getSource() instanceof Component)) {
                hidePopup();
                return;
            }
            
            Component comp = (Component)aWTEvent.getSource();
            Container par = SwingUtilities.getAncestorNamed(POPUP_NAME, comp); //NOI18N
            // Container barpar = SwingUtilities.getAncestorOfClass(PopupUtil.class, comp);
            // if (par == null && barpar == null) {
            if ( par == null ) {
                hidePopup();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:PopupUtil.java

示例9: eventDispatched

import java.awt.AWTEvent; //导入依赖的package包/类
@Override
public void eventDispatched(AWTEvent event) {
    if (event.getSource() == this) {
        return;
    }
    if (event instanceof KeyEvent) {
        if (event.getID() == KeyEvent.KEY_PRESSED) {
            if( !changeSelection( (KeyEvent)event ) ) {
                Toolkit.getDefaultToolkit().removeAWTEventListener(this);
                hideCurrentPopup();
            } else {
                ((KeyEvent)event).consume();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ButtonPopupSwitcher.java

示例10: EventQueueDelegateFromMap

import java.awt.AWTEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public EventQueueDelegateFromMap(Map<String, Map<String, Object>> objectMap) {
    Map<String, Object> methodMap = objectMap.get("afterDispatch");
    afterDispatchEventArgument = (AWTEvent[]) methodMap.get("event");
    afterDispatchHandleArgument = (Object[]) methodMap.get("handle");
    afterDispatchCallable = (Callable<Void>) methodMap.get("method");

    methodMap = objectMap.get("beforeDispatch");
    beforeDispatchEventArgument = (AWTEvent[]) methodMap.get("event");
    beforeDispatchCallable = (Callable<Object>) methodMap.get("method");

    methodMap = objectMap.get("getNextEvent");
    getNextEventEventQueueArgument =
        (EventQueue[]) methodMap.get("eventQueue");
    getNextEventCallable = (Callable<AWTEvent>) methodMap.get("method");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:SwingUtilities3.java

示例11: eventDispatched

import java.awt.AWTEvent; //导入依赖的package包/类
public void eventDispatched(AWTEvent e) {
    if (popup == null) return;
    
    // Not a mouse event
    if (!(e instanceof MouseEvent)) return;
    MouseEvent me = (MouseEvent)e;
    
    // Event not relevant
    if (isIgnoreEvent(me)) return;
    
    // Mouse moved over popup
    if (me.getID() == MouseEvent.MOUSE_MOVED && overPopup(me)) return;
    
    if (!overPopup(me)) {
        // Mouse event outside of popup
        hidePopup();
    } else if (isForwardEvent(me)) {
        // Mouse event on popup, to be forwarded to table
        Point popupPoint = popupLocation;
        hidePopup();
        forwardEvent(me, popupPoint);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ProfilerTableHover.java

示例12: selectItem

import java.awt.AWTEvent; //导入依赖的package包/类
/**
 * Creates and shows the popup with given <code>items</code>. When user
 * selects an item <code>SwitcherTableItem.Activatable.activate()</code> is
 * called. So what exactly happens depends on the concrete
 * <code>SwitcherTableItem.Activatable</code> implementation.
 * Selection is made when user releases a <code>releaseKey</code> passed on
 * as a parameter. If user releases the <code>releaseKey</code> before a
 * specified time (<code>TIME_TO_SHOW</code>) expires the popup won't show
 * at all and switch to the last used document will be performed
 * immediately.
 *
 * A popup appears on <code>x</code>, <code>y</code> coordinates.
 */
public static void selectItem(SwitcherTableItem items[], int releaseKey,
        int triggerKey, boolean forward, boolean cancelOnFocusLost) {
    // reject multiple invocations
    if (invokerTimerRunning) {
        return;
    }
    KeyboardPopupSwitcher.items = items;
    KeyboardPopupSwitcher.releaseKey = releaseKey;
    KeyboardPopupSwitcher.triggerKey = triggerKey;
    KeyboardPopupSwitcher.cancelOnFocusLost = cancelOnFocusLost;
    invokerTimer = new Timer(TIME_TO_SHOW, new PopupInvoker(forward));
    invokerTimer.setRepeats(false);
    invokerTimer.start();
    invokerTimerRunning = true;
    awtListener = new AWTListener();
    Toolkit.getDefaultToolkit().addAWTEventListener(awtListener, AWTEvent.KEY_EVENT_MASK);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:KeyboardPopupSwitcher.java

示例13: eventDispatched

import java.awt.AWTEvent; //导入依赖的package包/类
/**
 * Popup should be closed under some circumstances. Namely when mouse is
 * pressed or released outside of popup or when key is pressed during the
 * time popup is visible.
 */
public void eventDispatched(AWTEvent event) {
    if (event.getSource() == this) {
        return;
    }
    if (event instanceof MouseEvent) {
        if (event.getID() == MouseEvent.MOUSE_RELEASED) {
            long time = System.currentTimeMillis();
            // check if button was just slowly clicked
            if (time - invocationTime > 500) {
                if (!onSwitcherTable((MouseEvent) event)) {
                    // Don't take any chances
                    hideCurrentPopup();
                }
            }
        } else if (event.getID() == MouseEvent.MOUSE_PRESSED) {
            if (!onSwitcherTable((MouseEvent) event)) {
                // Don't take any chances
                if (event.getSource() != invokingComponent) {
                    // If it's the invoker, don't do anything - it will
                    // generate another call to invoke(), which will do the
                    // hiding - if we do it here, it will get shown again
                    // when the button processes the event
                    hideCurrentPopup();
                }
            }
        }
    } else if (event instanceof KeyEvent) {
        if (event.getID() == KeyEvent.KEY_PRESSED) {
            Toolkit.getDefaultToolkit().removeAWTEventListener(this);
            hideCurrentPopup();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:ButtonPopupSwitcher.java

示例14: run

import java.awt.AWTEvent; //导入依赖的package包/类
public void run()
{
  while( isModal() )
  {
    handleIdleTime();
    try
    {
      AWTEvent event = Toolkit.getDefaultToolkit().getSystemEventQueue().getNextEvent();
      dispatchEvent( event );
    }
    catch( Throwable e )
    {
      handleUncaughtException( e );
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:17,代码来源:ModalEventQueue.java

示例15: eventDispatched

import java.awt.AWTEvent; //导入依赖的package包/类
@Override
public void eventDispatched(AWTEvent e) {
	if (e instanceof MouseEvent) {
		MouseEvent me = (MouseEvent) e;
		if (!SwingUtilities.isDescendingFrom(me.getComponent(), target)) {
			return;
		}
		if (me.getID() == MouseEvent.MOUSE_RELEASED) {
			// stop when mouse released
			mouseOnScreenPoint = null;
			if (timer.isRunning()) {
				timer.stop();
			}
		} else if (me.getID() == MouseEvent.MOUSE_DRAGGED && me.getComponent() == target) {
			mouseOnScreenPoint = me.getLocationOnScreen();
		} else if (me.getID() == MouseEvent.MOUSE_PRESSED && me.getComponent() == target) {
			mouseOnScreenPoint = me.getLocationOnScreen();
			timer.start();
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:22,代码来源:PanningManager.java


注:本文中的java.awt.AWTEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。