Java Code Examples for javax.swing.SwingUtilities#processKeyBindings()

The following examples show how to use javax.swing.SwingUtilities#processKeyBindings() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}
 
Example 2
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}
 
Example 3
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}
 
Example 4
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}
 
Example 5
Source Project: netbeans   File: CodeTemplatesTest.java    License: Apache License 2.0 6 votes vote down vote up
@RandomlyFails
public void testMemoryRelease() throws Exception { // Issue #147984
    org.netbeans.junit.Log.enableInstances(Logger.getLogger("TIMER"), "CodeTemplateInsertHandler", Level.FINEST);

    JEditorPane pane = new JEditorPane();
    NbEditorKit kit = new NbEditorKit();
    pane.setEditorKit(kit);
    Document doc = pane.getDocument();
    assertTrue(doc instanceof BaseDocument);
    CodeTemplateManager mgr = CodeTemplateManager.get(doc);
    String templateText = "Test with parm ";
    CodeTemplate ct = mgr.createTemporary(templateText + " ${a}");
    ct.insert(pane);
    assertEquals(templateText + " a", doc.getText(0, doc.getLength()));

    // Send Enter to stop editing
    KeyEvent enterKeyEvent = new KeyEvent(pane, KeyEvent.KEY_PRESSED,
            EventQueue.getMostRecentEventTime(),
            0, KeyEvent.VK_ENTER, KeyEvent.CHAR_UNDEFINED);

    SwingUtilities.processKeyBindings(enterKeyEvent);
    // CT editing should be finished

    org.netbeans.junit.Log.assertInstances("CodeTemplateInsertHandler instances not GCed");
}
 
Example 6
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}
 
Example 7
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}
 
Example 8
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}
 
Example 9
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}
 
Example 10
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}
 
Example 11
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}
 
Example 12
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}
 
Example 13
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}
 
Example 14
protected void sendEventToDelegate(final AWTEvent e) {
    if (getDelegate() == null || !isShowing() || !isEnabled()) {
        return;
    }
    synchronized (getDelegateLock()) {
        AWTEvent delegateEvent = createDelegateEvent(e);
        if (delegateEvent != null) {
            AWTAccessor.getComponentAccessor()
                    .processEvent((Component) delegateEvent.getSource(),
                            delegateEvent);
            if (delegateEvent instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) delegateEvent;
                SwingUtilities.processKeyBindings(ke);
            }
        }
    }
}