Java Code Examples for java.awt.im.InputContext#endComposition()

The following examples show how to use java.awt.im.InputContext#endComposition() . 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
Source File: JTextComponent.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public boolean importData(JComponent comp, Transferable t) {
    if (comp instanceof JTextComponent) {
        DataFlavor flavor = getFlavor(t.getTransferDataFlavors());

        if (flavor != null) {
            InputContext ic = comp.getInputContext();
            if (ic != null) {
                ic.endComposition();
            }
            try {
                String data = (String)t.getTransferData(flavor);

                ((JTextComponent)comp).replaceSelection(data);
                return true;
            } catch (UnsupportedFlavorException ufe) {
            } catch (IOException ioe) {
            }
        }
    }
    return false;
}
 
Example 2
Source File: JTextComponent.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public boolean importData(JComponent comp, Transferable t) {
    if (comp instanceof JTextComponent) {
        DataFlavor flavor = getFlavor(t.getTransferDataFlavors());

        if (flavor != null) {
            InputContext ic = comp.getInputContext();
            if (ic != null) {
                ic.endComposition();
            }
            try {
                String data = (String)t.getTransferData(flavor);

                ((JTextComponent)comp).replaceSelection(data);
                return true;
            } catch (UnsupportedFlavorException ufe) {
            } catch (IOException ioe) {
            }
        }
    }
    return false;
}
 
Example 3
Source File: JTextComponent.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public boolean importData(JComponent comp, Transferable t) {
    if (comp instanceof JTextComponent) {
        DataFlavor flavor = getFlavor(t.getTransferDataFlavors());

        if (flavor != null) {
            InputContext ic = comp.getInputContext();
            if (ic != null) {
                ic.endComposition();
            }
            try {
                String data = (String)t.getTransferData(flavor);

                ((JTextComponent)comp).replaceSelection(data);
                return true;
            } catch (UnsupportedFlavorException ufe) {
            } catch (IOException ioe) {
            }
        }
    }
    return false;
}
 
Example 4
Source File: JTextComponent.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean importData(JComponent comp, Transferable t) {
    if (comp instanceof JTextComponent) {
        DataFlavor flavor = getFlavor(t.getTransferDataFlavors());

        if (flavor != null) {
            InputContext ic = comp.getInputContext();
            if (ic != null) {
                ic.endComposition();
            }
            try {
                String data = (String)t.getTransferData(flavor);

                ((JTextComponent)comp).replaceSelection(data);
                return true;
            } catch (UnsupportedFlavorException ufe) {
            } catch (IOException ioe) {
            }
        }
    }
    return false;
}
 
Example 5
Source File: JTextComponent.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean importData(JComponent comp, Transferable t) {
    if (comp instanceof JTextComponent) {
        DataFlavor flavor = getFlavor(t.getTransferDataFlavors());

        if (flavor != null) {
            InputContext ic = comp.getInputContext();
            if (ic != null) {
                ic.endComposition();
            }
            try {
                String data = (String)t.getTransferData(flavor);

                ((JTextComponent)comp).replaceSelection(data);
                return true;
            } catch (UnsupportedFlavorException ufe) {
            } catch (IOException ioe) {
            }
        }
    }
    return false;
}
 
Example 6
Source File: JTextComponent.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public boolean importData(JComponent comp, Transferable t) {
    if (comp instanceof JTextComponent) {
        DataFlavor flavor = getFlavor(t.getTransferDataFlavors());

        if (flavor != null) {
            InputContext ic = comp.getInputContext();
            if (ic != null) {
                ic.endComposition();
            }
            try {
                String data = (String)t.getTransferData(flavor);

                ((JTextComponent)comp).replaceSelection(data);
                return true;
            } catch (UnsupportedFlavorException ufe) {
            } catch (IOException ioe) {
            }
        }
    }
    return false;
}
 
Example 7
Source File: JTextComponent.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public boolean importData(JComponent comp, Transferable t) {
    if (comp instanceof JTextComponent) {
        DataFlavor flavor = getFlavor(t.getTransferDataFlavors());

        if (flavor != null) {
            InputContext ic = comp.getInputContext();
            if (ic != null) {
                ic.endComposition();
            }
            try {
                String data = (String)t.getTransferData(flavor);

                ((JTextComponent)comp).replaceSelection(data);
                return true;
            } catch (UnsupportedFlavorException ufe) {
            } catch (IOException ioe) {
            }
        }
    }
    return false;
}
 
Example 8
Source File: JTextComponent.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public boolean importData(JComponent comp, Transferable t) {
    if (comp instanceof JTextComponent) {
        DataFlavor flavor = getFlavor(t.getTransferDataFlavors());

        if (flavor != null) {
            InputContext ic = comp.getInputContext();
            if (ic != null) {
                ic.endComposition();
            }
            try {
                String data = (String)t.getTransferData(flavor);

                ((JTextComponent)comp).replaceSelection(data);
                return true;
            } catch (UnsupportedFlavorException ufe) {
            } catch (IOException ioe) {
            }
        }
    }
    return false;
}
 
Example 9
Source File: JTextComponent.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public boolean importData(JComponent comp, Transferable t) {
    if (comp instanceof JTextComponent) {
        DataFlavor flavor = getFlavor(t.getTransferDataFlavors());

        if (flavor != null) {
            InputContext ic = comp.getInputContext();
            if (ic != null) {
                ic.endComposition();
            }
            try {
                String data = (String)t.getTransferData(flavor);

                ((JTextComponent)comp).replaceSelection(data);
                return true;
            } catch (UnsupportedFlavorException ufe) {
            } catch (IOException ioe) {
            }
        }
    }
    return false;
}
 
Example 10
Source File: JTextComponent.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public boolean importData(JComponent comp, Transferable t) {
    if (comp instanceof JTextComponent) {
        DataFlavor flavor = getFlavor(t.getTransferDataFlavors());

        if (flavor != null) {
            InputContext ic = comp.getInputContext();
            if (ic != null) {
                ic.endComposition();
            }
            try {
                String data = (String)t.getTransferData(flavor);

                ((JTextComponent)comp).replaceSelection(data);
                return true;
            } catch (UnsupportedFlavorException ufe) {
            } catch (IOException ioe) {
            }
        }
    }
    return false;
}
 
Example 11
Source File: JFormattedTextField.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Processes any focus events, such as
 * <code>FocusEvent.FOCUS_GAINED</code> or
 * <code>FocusEvent.FOCUS_LOST</code>.
 *
 * @param e the <code>FocusEvent</code>
 * @see FocusEvent
 */
protected void processFocusEvent(FocusEvent e) {
    super.processFocusEvent(e);

    // ignore temporary focus event
    if (e.isTemporary()) {
        return;
    }

    if (isEdited() && e.getID() == FocusEvent.FOCUS_LOST) {
        InputContext ic = getInputContext();
        if (focusLostHandler == null) {
            focusLostHandler = new FocusLostHandler();
        }

        // if there is a composed text, process it first
        if ((ic != null) && composedTextExists) {
            ic.endComposition();
            EventQueue.invokeLater(focusLostHandler);
        } else {
            focusLostHandler.run();
        }
    }
    else if (!isEdited()) {
        // reformat
        setValue(getValue(), true, true);
    }
}
 
Example 12
Source File: JFormattedTextField.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Processes any focus events, such as
 * <code>FocusEvent.FOCUS_GAINED</code> or
 * <code>FocusEvent.FOCUS_LOST</code>.
 *
 * @param e the <code>FocusEvent</code>
 * @see FocusEvent
 */
protected void processFocusEvent(FocusEvent e) {
    super.processFocusEvent(e);

    // ignore temporary focus event
    if (e.isTemporary()) {
        return;
    }

    if (isEdited() && e.getID() == FocusEvent.FOCUS_LOST) {
        InputContext ic = getInputContext();
        if (focusLostHandler == null) {
            focusLostHandler = new FocusLostHandler();
        }

        // if there is a composed text, process it first
        if ((ic != null) && composedTextExists) {
            ic.endComposition();
            EventQueue.invokeLater(focusLostHandler);
        } else {
            focusLostHandler.run();
        }
    }
    else if (!isEdited()) {
        // reformat
        setValue(getValue(), true, true);
    }
}
 
Example 13
Source File: JFormattedTextField.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Processes any focus events, such as
 * <code>FocusEvent.FOCUS_GAINED</code> or
 * <code>FocusEvent.FOCUS_LOST</code>.
 *
 * @param e the <code>FocusEvent</code>
 * @see FocusEvent
 */
protected void processFocusEvent(FocusEvent e) {
    super.processFocusEvent(e);

    // ignore temporary focus event
    if (e.isTemporary()) {
        return;
    }

    if (isEdited() && e.getID() == FocusEvent.FOCUS_LOST) {
        InputContext ic = getInputContext();
        if (focusLostHandler == null) {
            focusLostHandler = new FocusLostHandler();
        }

        // if there is a composed text, process it first
        if ((ic != null) && composedTextExists) {
            ic.endComposition();
            EventQueue.invokeLater(focusLostHandler);
        } else {
            focusLostHandler.run();
        }
    }
    else if (!isEdited()) {
        // reformat
        setValue(getValue(), true, true);
    }
}
 
Example 14
Source File: JFormattedTextField.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Processes any focus events, such as
 * <code>FocusEvent.FOCUS_GAINED</code> or
 * <code>FocusEvent.FOCUS_LOST</code>.
 *
 * @param e the <code>FocusEvent</code>
 * @see FocusEvent
 */
protected void processFocusEvent(FocusEvent e) {
    super.processFocusEvent(e);

    // ignore temporary focus event
    if (e.isTemporary()) {
        return;
    }

    if (isEdited() && e.getID() == FocusEvent.FOCUS_LOST) {
        InputContext ic = getInputContext();
        if (focusLostHandler == null) {
            focusLostHandler = new FocusLostHandler();
        }

        // if there is a composed text, process it first
        if ((ic != null) && composedTextExists) {
            ic.endComposition();
            EventQueue.invokeLater(focusLostHandler);
        } else {
            focusLostHandler.run();
        }
    }
    else if (!isEdited()) {
        // reformat
        setValue(getValue(), true, true);
    }
}
 
Example 15
Source File: JFormattedTextField.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Processes any focus events, such as
 * <code>FocusEvent.FOCUS_GAINED</code> or
 * <code>FocusEvent.FOCUS_LOST</code>.
 *
 * @param e the <code>FocusEvent</code>
 * @see FocusEvent
 */
protected void processFocusEvent(FocusEvent e) {
    super.processFocusEvent(e);

    // ignore temporary focus event
    if (e.isTemporary()) {
        return;
    }

    if (isEdited() && e.getID() == FocusEvent.FOCUS_LOST) {
        InputContext ic = getInputContext();
        if (focusLostHandler == null) {
            focusLostHandler = new FocusLostHandler();
        }

        // if there is a composed text, process it first
        if ((ic != null) && composedTextExists) {
            ic.endComposition();
            EventQueue.invokeLater(focusLostHandler);
        } else {
            focusLostHandler.run();
        }
    }
    else if (!isEdited()) {
        // reformat
        setValue(getValue(), true, true);
    }
}
 
Example 16
Source File: JFormattedTextField.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Processes any focus events, such as
 * <code>FocusEvent.FOCUS_GAINED</code> or
 * <code>FocusEvent.FOCUS_LOST</code>.
 *
 * @param e the <code>FocusEvent</code>
 * @see FocusEvent
 */
protected void processFocusEvent(FocusEvent e) {
    super.processFocusEvent(e);

    // ignore temporary focus event
    if (e.isTemporary()) {
        return;
    }

    if (isEdited() && e.getID() == FocusEvent.FOCUS_LOST) {
        InputContext ic = getInputContext();
        if (focusLostHandler == null) {
            focusLostHandler = new FocusLostHandler();
        }

        // if there is a composed text, process it first
        if ((ic != null) && composedTextExists) {
            ic.endComposition();
            EventQueue.invokeLater(focusLostHandler);
        } else {
            focusLostHandler.run();
        }
    }
    else if (!isEdited()) {
        // reformat
        setValue(getValue(), true, true);
    }
}
 
Example 17
Source File: JFormattedTextField.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Processes any focus events, such as
 * <code>FocusEvent.FOCUS_GAINED</code> or
 * <code>FocusEvent.FOCUS_LOST</code>.
 *
 * @param e the <code>FocusEvent</code>
 * @see FocusEvent
 */
protected void processFocusEvent(FocusEvent e) {
    super.processFocusEvent(e);

    // ignore temporary focus event
    if (e.isTemporary()) {
        return;
    }

    if (isEdited() && e.getID() == FocusEvent.FOCUS_LOST) {
        InputContext ic = getInputContext();
        if (focusLostHandler == null) {
            focusLostHandler = new FocusLostHandler();
        }

        // if there is a composed text, process it first
        if ((ic != null) && composedTextExists) {
            ic.endComposition();
            EventQueue.invokeLater(focusLostHandler);
        } else {
            focusLostHandler.run();
        }
    }
    else if (!isEdited()) {
        // reformat
        setValue(getValue(), true, true);
    }
}
 
Example 18
Source File: JFormattedTextField.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Processes any focus events, such as
 * <code>FocusEvent.FOCUS_GAINED</code> or
 * <code>FocusEvent.FOCUS_LOST</code>.
 *
 * @param e the <code>FocusEvent</code>
 * @see FocusEvent
 */
protected void processFocusEvent(FocusEvent e) {
    super.processFocusEvent(e);

    // ignore temporary focus event
    if (e.isTemporary()) {
        return;
    }

    if (isEdited() && e.getID() == FocusEvent.FOCUS_LOST) {
        InputContext ic = getInputContext();
        if (focusLostHandler == null) {
            focusLostHandler = new FocusLostHandler();
        }

        // if there is a composed text, process it first
        if ((ic != null) && composedTextExists) {
            ic.endComposition();
            EventQueue.invokeLater(focusLostHandler);
        } else {
            focusLostHandler.run();
        }
    }
    else if (!isEdited()) {
        // reformat
        setValue(getValue(), true, true);
    }
}
 
Example 19
Source File: JFormattedTextField.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Processes any focus events, such as
 * <code>FocusEvent.FOCUS_GAINED</code> or
 * <code>FocusEvent.FOCUS_LOST</code>.
 *
 * @param e the <code>FocusEvent</code>
 * @see FocusEvent
 */
protected void processFocusEvent(FocusEvent e) {
    super.processFocusEvent(e);

    // ignore temporary focus event
    if (e.isTemporary()) {
        return;
    }

    if (isEdited() && e.getID() == FocusEvent.FOCUS_LOST) {
        InputContext ic = getInputContext();
        if (focusLostHandler == null) {
            focusLostHandler = new FocusLostHandler();
        }

        // if there is a composed text, process it first
        if ((ic != null) && composedTextExists) {
            ic.endComposition();
            EventQueue.invokeLater(focusLostHandler);
        } else {
            focusLostHandler.run();
        }
    }
    else if (!isEdited()) {
        // reformat
        setValue(getValue(), true, true);
    }
}
 
Example 20
Source File: JFormattedTextField.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Processes any focus events, such as
 * <code>FocusEvent.FOCUS_GAINED</code> or
 * <code>FocusEvent.FOCUS_LOST</code>.
 *
 * @param e the <code>FocusEvent</code>
 * @see FocusEvent
 */
protected void processFocusEvent(FocusEvent e) {
    super.processFocusEvent(e);

    // ignore temporary focus event
    if (e.isTemporary()) {
        return;
    }

    if (isEdited() && e.getID() == FocusEvent.FOCUS_LOST) {
        InputContext ic = getInputContext();
        if (focusLostHandler == null) {
            focusLostHandler = new FocusLostHandler();
        }

        // if there is a composed text, process it first
        if ((ic != null) && composedTextExists) {
            ic.endComposition();
            EventQueue.invokeLater(focusLostHandler);
        } else {
            focusLostHandler.run();
        }
    }
    else if (!isEdited()) {
        // reformat
        setValue(getValue(), true, true);
    }
}