本文整理匯總了Java中java.awt.event.InputMethodEvent.CARET_POSITION_CHANGED屬性的典型用法代碼示例。如果您正苦於以下問題:Java InputMethodEvent.CARET_POSITION_CHANGED屬性的具體用法?Java InputMethodEvent.CARET_POSITION_CHANGED怎麽用?Java InputMethodEvent.CARET_POSITION_CHANGED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.awt.event.InputMethodEvent
的用法示例。
在下文中一共展示了InputMethodEvent.CARET_POSITION_CHANGED屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processInputMethodEvent
@Override
protected void processInputMethodEvent(InputMethodEvent e) {
super.processInputMethodEvent(e);
if (!e.isConsumed()) {
switch (e.getID()) {
case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
myEditor.replaceInputMethodText(e);
// No breaks over here.
//noinspection fallthrough
case InputMethodEvent.CARET_POSITION_CHANGED:
myEditor.inputMethodCaretPositionChanged(e);
break;
}
e.consume();
}
}
示例2: processInputMethodEventImpl
private void processInputMethodEventImpl(InputMethodEvent e,
Collection<InputMethodListener> c) {
for (InputMethodListener listener : c) {
switch (e.getID()) {
case InputMethodEvent.CARET_POSITION_CHANGED:
listener.caretPositionChanged(e);
break;
case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
listener.inputMethodTextChanged(e);
break;
}
}
}
示例3: processInputMethodEvent
/**
* Called when an input method event is dispatched and component events are
* enabled. This method passes the event along to any listeners that are
* attached.
*
* @param e the <code>InputMethodEvent</code> to process
* @throws NullPointerException if e is null
* @see InputMethodListener
* @see #addInputMethodListener(InputMethodListener)
* @see #enableEvents(long)
* @since 1.2
*/
protected void processInputMethodEvent(InputMethodEvent e)
{
if (inputMethodListener == null)
return;
switch (e.id)
{
case InputMethodEvent.CARET_POSITION_CHANGED:
inputMethodListener.caretPositionChanged(e);
break;
case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
inputMethodListener.inputMethodTextChanged(e);
break;
}
}
示例4: processIMEvent
public static void processIMEvent(final InputMethodListener listener,
final InputMethodEvent e) {
if (e.getID() == InputMethodEvent.CARET_POSITION_CHANGED) {
listener.caretPositionChanged(e);
}
if (e.getID() == InputMethodEvent.INPUT_METHOD_TEXT_CHANGED) {
listener.inputMethodTextChanged(e);
}
}
示例5: main
public static void main(String[] args) throws Exception {
ThreadGroup stubTG = new ThreadGroup(getRootThreadGroup(), "Stub Thread Group");
ThreadGroup swingTG = new ThreadGroup(getRootThreadGroup(), "SwingTG");
try {
Thread stubThread = new Thread(stubTG, SunToolkit::createNewAppContext);
stubThread.start();
stubThread.join();
CountDownLatch startSwingLatch = new CountDownLatch(1);
new Thread(swingTG, () -> {
SunToolkit.createNewAppContext();
SwingUtilities.invokeLater(() -> {
frame = new JFrame();
component = new JLabel("Test Text");
frame.add(component);
frame.setBounds(100, 100, 100, 100);
frame.setVisible(true);
startSwingLatch.countDown();
});
}).start();
startSwingLatch.await();
AtomicReference<Exception> caughtException = new AtomicReference<>();
Thread checkThread = new Thread(getRootThreadGroup(), () -> {
try {
// If the bug is present this will throw exception
new InputMethodEvent(component,
InputMethodEvent.CARET_POSITION_CHANGED,
TextHitInfo.leading(0),
TextHitInfo.trailing(0));
} catch (Exception e) {
caughtException.set(e);
}
});
checkThread.start();
checkThread.join();
if (caughtException.get() != null) {
throw new RuntimeException("Failed. Caught exception!", caughtException.get());
}
} finally {
new Thread(swingTG, () -> SwingUtilities.invokeLater(() -> {
if (frame != null) {
frame.dispose();
}
})).start();
}
}
示例6: eventTypeEnabled
/**
* Tells whether or not an event type is enabled.
*/
boolean eventTypeEnabled (int type)
{
if (type > AWTEvent.RESERVED_ID_MAX)
return true;
switch (type)
{
case HierarchyEvent.HIERARCHY_CHANGED:
return (hierarchyListener != null
|| (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0);
case HierarchyEvent.ANCESTOR_MOVED:
case HierarchyEvent.ANCESTOR_RESIZED:
return (hierarchyBoundsListener != null
|| (eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0);
case ComponentEvent.COMPONENT_HIDDEN:
case ComponentEvent.COMPONENT_MOVED:
case ComponentEvent.COMPONENT_RESIZED:
case ComponentEvent.COMPONENT_SHOWN:
return (componentListener != null
|| (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0);
case KeyEvent.KEY_PRESSED:
case KeyEvent.KEY_RELEASED:
case KeyEvent.KEY_TYPED:
return (keyListener != null
|| (eventMask & AWTEvent.KEY_EVENT_MASK) != 0);
case MouseEvent.MOUSE_CLICKED:
case MouseEvent.MOUSE_ENTERED:
case MouseEvent.MOUSE_EXITED:
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
return (mouseListener != null
|| (eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0);
case MouseEvent.MOUSE_MOVED:
case MouseEvent.MOUSE_DRAGGED:
return (mouseMotionListener != null
|| (eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0);
case MouseEvent.MOUSE_WHEEL:
return (mouseWheelListener != null
|| (eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0);
case FocusEvent.FOCUS_GAINED:
case FocusEvent.FOCUS_LOST:
return (focusListener != null
|| (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0);
case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
case InputMethodEvent.CARET_POSITION_CHANGED:
return (inputMethodListener != null
|| (eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0);
case PaintEvent.PAINT:
case PaintEvent.UPDATE:
return (eventMask & AWTEvent.PAINT_EVENT_MASK) != 0;
default:
return false;
}
}
示例7: eventTypeEnabled
/**
* Tells whether or not an event type is enabled.
*/
boolean eventTypeEnabled (int type)
{
if (type > AWTEvent.RESERVED_ID_MAX)
return true;
switch (type)
{
case HierarchyEvent.HIERARCHY_CHANGED:
return (hierarchyListener != null
|| (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0);
case HierarchyEvent.ANCESTOR_MOVED:
case HierarchyEvent.ANCESTOR_RESIZED:
return (hierarchyBoundsListener != null
|| (eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0);
case ComponentEvent.COMPONENT_HIDDEN:
case ComponentEvent.COMPONENT_MOVED:
case ComponentEvent.COMPONENT_RESIZED:
case ComponentEvent.COMPONENT_SHOWN:
return (componentListener != null
|| (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0);
case KeyEvent.KEY_PRESSED:
case KeyEvent.KEY_RELEASED:
case KeyEvent.KEY_TYPED:
return (keyListener != null
|| (eventMask & AWTEvent.KEY_EVENT_MASK) != 0);
case MouseEvent.MOUSE_CLICKED:
case MouseEvent.MOUSE_ENTERED:
case MouseEvent.MOUSE_EXITED:
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
return (mouseListener != null
|| (eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0);
case MouseEvent.MOUSE_MOVED:
case MouseEvent.MOUSE_DRAGGED:
return (mouseMotionListener != null
|| (eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0);
case MouseEvent.MOUSE_WHEEL:
return (mouseWheelListener != null
|| (eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0);
case FocusEvent.FOCUS_GAINED:
case FocusEvent.FOCUS_LOST:
return (focusListener != null
|| (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0);
case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
case InputMethodEvent.CARET_POSITION_CHANGED:
return (inputMethodListener != null
|| (eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0);
case PaintEvent.PAINT:
case PaintEvent.UPDATE:
return (eventMask & AWTEvent.PAINT_EVENT_MASK) != 0;
default:
return false;
}
}
示例8: processInputMethodEvent
/**
* Processes input method events occurring on this component by
* dispatching them to any registered
* <code>InputMethodListener</code> objects.
* <p>
* This method is not called unless input method events
* are enabled for this component. Input method events are enabled
* when one of the following occurs:
* <p><ul>
* <li>An <code>InputMethodListener</code> object is registered
* via <code>addInputMethodListener</code>.
* <li>Input method events are enabled via <code>enableEvents</code>.
* </ul>
* <p>Note that if the event parameter is <code>null</code>
* the behavior is unspecified and may result in an
* exception.
*
* @param e the input method event
* @see java.awt.event.InputMethodEvent
* @see java.awt.event.InputMethodListener
* @see #addInputMethodListener
* @see #enableEvents
* @since 1.2
*/
protected void processInputMethodEvent(InputMethodEvent e) {
InputMethodListener listener = inputMethodListener;
if (listener != null) {
int id = e.getID();
switch (id) {
case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
listener.inputMethodTextChanged(e);
break;
case InputMethodEvent.CARET_POSITION_CHANGED:
listener.caretPositionChanged(e);
break;
}
}
}
示例9: processInputMethodEvent
/**
* Processes input method events occurring on this component by
* dispatching them to any registered
* <code>InputMethodListener</code> objects.
* <p>
* This method is not called unless input method events
* are enabled for this component. Input method events are enabled
* when one of the following occurs:
* <ul>
* <li>An <code>InputMethodListener</code> object is registered
* via <code>addInputMethodListener</code>.
* <li>Input method events are enabled via <code>enableEvents</code>.
* </ul>
* <p>Note that if the event parameter is <code>null</code>
* the behavior is unspecified and may result in an
* exception.
*
* @param e the input method event
* @see java.awt.event.InputMethodEvent
* @see java.awt.event.InputMethodListener
* @see #addInputMethodListener
* @see #enableEvents
* @since 1.2
*/
protected void processInputMethodEvent(InputMethodEvent e) {
InputMethodListener listener = inputMethodListener;
if (listener != null) {
int id = e.getID();
switch (id) {
case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
listener.inputMethodTextChanged(e);
break;
case InputMethodEvent.CARET_POSITION_CHANGED:
listener.caretPositionChanged(e);
break;
}
}
}