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


Java Component.dispatchEvent方法代码示例

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


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

示例1: dispatchEvent

import java.awt.Component; //导入方法依赖的package包/类
private void dispatchEvent(final KeyEvent ke, final Component comp) throws Exception {
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                comp.dispatchEvent(ke);
            }
        });
        
    }  else {
        comp.dispatchEvent(ke);
    }
    sleep();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:InplaceEditorNoModifyOnTextChangeContractComboEditorTest.java

示例2: dispatchNextGuiEvent

import java.awt.Component; //导入方法依赖的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);
        }
    }
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:23,代码来源:SwingGui.java

示例3: dispatchInputMethodEvent

import java.awt.Component; //导入方法依赖的package包/类
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:InputMethodContext.java

示例4: dispatchEvent

import java.awt.Component; //导入方法依赖的package包/类
private void dispatchEvent(final KeyEvent ke, final Component comp) throws Exception {
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                comp.dispatchEvent(ke);
            }
        });
        
    }  else {
        comp.dispatchEvent(ke);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:InplaceEditorNoModifyOnTextChangeContractBooleanEditorTest.java

示例5: ctrlPressKey

import java.awt.Component; //导入方法依赖的package包/类
private void ctrlPressKey(final Component target, final int key) throws Exception {
    if (SwingUtilities.isEventDispatchThread()) {
        KeyEvent k = new KeyEvent(target, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), KeyEvent.CTRL_MASK, key, (char) key);
        target.dispatchEvent(k);
    } else {
        
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                KeyEvent ke = new KeyEvent(target, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), KeyEvent.CTRL_MASK, key, (char) key);
                target.dispatchEvent(ke);
            }
        });
        sleep();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:EditableDisplayerTest.java

示例6: processKeyEvent

import java.awt.Component; //导入方法依赖的package包/类
@Override
protected void processKeyEvent(KeyEvent e) {

    if (!isEditing())
        super.processKeyEvent(e);
    else {
        Component component = ((DefaultCellEditor) getCellEditor(lastRow, lastColumn)).getComponent();
        component.requestFocus();
        component.dispatchEvent(new KeyEvent(component, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar()));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:KeymapPanel.java

示例7: redispatchEvent

import java.awt.Component; //导入方法依赖的package包/类
private void redispatchEvent(MouseEvent e, Component component) {
    Point componentPoint
            = SwingUtilities.convertPoint(glassPane,
                                          e.getPoint(),
                                          component);
    component.dispatchEvent(
            new MouseEvent(component,
                           e.getID(),
                           e.getWhen(),
                           e.getModifiers(),
                           componentPoint.x,
                           componentPoint.y,
                           e.getClickCount(),
                           e.isPopupTrigger()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:SimpleTestStepLocation.java

示例8: processMouseEvent

import java.awt.Component; //导入方法依赖的package包/类
public void processMouseEvent(MouseEvent e) {
    if (e instanceof MouseWheelEvent) {
        Component target = JCheckTree.this.getParent();
        if (target == null || !(target instanceof JViewport))
            target = JCheckTree.this;
        MouseEvent mwe = SwingUtilities.convertMouseEvent(
                JCheckTree.this, (MouseWheelEvent)e, target);
        target.dispatchEvent((MouseWheelEvent)mwe);
    } else {
        super.processMouseEvent((MouseEvent)e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:JCheckTree.java

示例9: processMouseEvent

import java.awt.Component; //导入方法依赖的package包/类
public void processMouseEvent(MouseEvent e) {
    if (e instanceof MouseWheelEvent) {
        Component target = JExtendedTree.this.getParent();
        if (target == null || !(target instanceof JViewport))
            target = JExtendedTree.this;
        MouseEvent mwe = SwingUtilities.convertMouseEvent(
                JExtendedTree.this, (MouseWheelEvent)e, target);
        target.dispatchEvent((MouseWheelEvent)mwe);
    } else {
        super.processMouseEvent((MouseEvent)e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:JExtendedTree.java

示例10: dispatchCommittedText

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Dispatches committed text to a client component.
 * Called by composition window.
 *
 * @param client The component that the text should get dispatched to.
 * @param text The iterator providing access to the committed
 *        (and possible composed) text.
 * @param committedCharacterCount The number of committed characters in the text.
 */
synchronized void dispatchCommittedText(Component client,
             AttributedCharacterIterator text,
             int committedCharacterCount) {
    // note that the client is not always the current client component -
    // some host input method adapters may dispatch input method events
    // through the Java event queue, and we may have switched clients while
    // the event was in the queue.
    if (committedCharacterCount == 0
            || text.getEndIndex() <= text.getBeginIndex()) {
        return;
    }
    long time = System.currentTimeMillis();
    dispatchingCommittedText = true;
    try {
        InputMethodRequests req = client.getInputMethodRequests();
        if (req != null) {
            // active client -> send text as InputMethodEvent
            int beginIndex = text.getBeginIndex();
            AttributedCharacterIterator toBeCommitted =
                (new AttributedString(text, beginIndex, beginIndex + committedCharacterCount)).getIterator();

            InputMethodEvent inputEvent = new InputMethodEvent(
                    client,
                    InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                    toBeCommitted,
                    committedCharacterCount,
                    null, null);

            client.dispatchEvent(inputEvent);
        } else {
            // passive client -> send text as KeyEvents
            char keyChar = text.first();
            while (committedCharacterCount-- > 0 && keyChar != CharacterIterator.DONE) {
                KeyEvent keyEvent = new KeyEvent(client, KeyEvent.KEY_TYPED,
                                             time, 0, KeyEvent.VK_UNDEFINED, keyChar);
                client.dispatchEvent(keyEvent);
                keyChar = text.next();
            }
        }
    } finally {
        dispatchingCommittedText = false;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:53,代码来源:InputMethodContext.java

示例11: redispatchComponent

import java.awt.Component; //导入方法依赖的package包/类
private boolean redispatchComponent(MouseEvent e) {
    Point p = e.getPoint();
    int index = list.locationToIndex(p);
    if (index < 0 || index >= list.getModel().getSize()) {
        return false;
    }

    ListCellRenderer renderer = list.getCellRenderer();
    if (null == renderer) {
        return false;
    }
    Component renComponent = renderer.getListCellRendererComponent(list, list.getModel().getElementAt(index), index, false, false);
    if (null == renComponent) {
        return false;
    }
    Rectangle rect = list.getCellBounds(index, index);
    if (null == rect) {
        return false;
    }
    renComponent.setBounds(0, 0, rect.width, rect.height);
    renComponent.doLayout();
    Point p3 = rect.getLocation();

    Point p2 = new Point(p.x - p3.x, p.y - p3.y);
    Component dispatchComponent =
            SwingUtilities.getDeepestComponentAt(renComponent,
            p2.x, p2.y);
    if ( e.isPopupTrigger() &&
         dispatchComponent instanceof LinkButton && 
         !((LinkButton)dispatchComponent).isHandlingPopupEvents() ) 
    {
        return false;
    } 
    if (dispatchComponent instanceof AbstractButton) {
        if (!((AbstractButton) dispatchComponent).isEnabled()) {
            return false;
        }
        Point p4 = SwingUtilities.convertPoint(renComponent, p2, dispatchComponent);
        MouseEvent newEvent = new MouseEvent(dispatchComponent,
                e.getID(),
                e.getWhen(),
                e.getModifiers(),
                p4.x, p4.y,
                e.getClickCount(),
                e.isPopupTrigger(),
                MouseEvent.NOBUTTON);
        dispatchComponent.dispatchEvent(newEvent);
        list.repaint(rect);
        e.consume();
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:54,代码来源:AbstractListUI.java

示例12: doCtrlPressKey

import java.awt.Component; //导入方法依赖的package包/类
private void doCtrlPressKey(final Component target, final int key) throws Exception {
    
    KeyEvent k = new KeyEvent(target, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), KeyEvent.CTRL_MASK, key, (char) key);
    target.dispatchEvent(k);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:EditableDisplayerTest.java


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