java.awt.im.InputContext Java Examples

The following examples show how to use java.awt.im.InputContext. 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 openjdk-jdk8u-backup 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 #2
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 #3
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 #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 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 #6
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 #7
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 #8
Source File: JTextComponent.java    From Bytecoder 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 #9
Source File: JTextComponent.java    From openjdk-jdk9 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-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: JTextComponent.java    From Java8CN 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 #12
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 #13
Source File: JTextComponent.java    From openjdk-8-source 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 #14
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 #15
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 #16
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 #17
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 #18
Source File: Game.java    From JavaGame with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @author Redomar
 * @version Alpha 1.8.4
 */
public Game() {
	context = InputContext.getInstance();

	// The game can only be played in one distinct window size
	setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
	setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
	setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));

	setFrame(new JFrame(NAME));                                             // Creates the frame with a defined name
	getFrame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);              // Exits the program when user closes the frame
	getFrame().setLayout(new BorderLayout());
	getFrame().add(this, BorderLayout.CENTER);                       // Centers the canvas inside the JFrame
	getFrame().pack();                                                      // Sizes the frame so that all its contents are at or above their preferred sizes
	getFrame().setResizable(false);
	getFrame().setLocationRelativeTo(null);                                 // Centres the window on the screen
	getFrame().setVisible(true);

	requestFocus();
	setDevMode(false);
	setClosing(false);
}
 
Example #19
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 #20
Source File: Window.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the input context for this window. A window always has an input context,
 * which is shared by subcomponents unless they create and set their own.
 * @see Component#getInputContext
 * @since 1.2
 */
public InputContext getInputContext() {
    synchronized (inputContextLock) {
        if (inputContext == null) {
            inputContext = InputContext.getInstance();
        }
    }
    return inputContext;
}
 
Example #21
Source File: JFormattedTextField.java    From openjdk-8-source 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 #22
Source File: JFormattedTextField.java    From jdk1.8-source-analysis 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 #23
Source File: Window.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the input context for this window. A window always has an input context,
 * which is shared by subcomponents unless they create and set their own.
 * @see Component#getInputContext
 * @since 1.2
 */
public InputContext getInputContext() {
    synchronized (inputContextLock) {
        if (inputContext == null) {
            inputContext = InputContext.getInstance();
        }
    }
    return inputContext;
}
 
Example #24
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 #25
Source File: JFormattedTextField.java    From hottub 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 #26
Source File: Window.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the input context for this window. A window always has an input context,
 * which is shared by subcomponents unless they create and set their own.
 * @see Component#getInputContext
 * @since 1.2
 */
public InputContext getInputContext() {
    synchronized (inputContextLock) {
        if (inputContext == null) {
            inputContext = InputContext.getInstance();
        }
    }
    return inputContext;
}
 
Example #27
Source File: Window.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the input context for this window. A window always has an input context,
 * which is shared by subcomponents unless they create and set their own.
 * @see Component#getInputContext
 * @since 1.2
 */
public InputContext getInputContext() {
    synchronized (inputContextLock) {
        if (inputContext == null) {
            inputContext = InputContext.getInstance();
        }
    }
    return inputContext;
}
 
Example #28
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 #29
Source File: Window.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the input context for this window. A window always has an input context,
 * which is shared by subcomponents unless they create and set their own.
 * @see Component#getInputContext
 * @since 1.2
 */
public InputContext getInputContext() {
    synchronized (inputContextLock) {
        if (inputContext == null) {
            inputContext = InputContext.getInstance();
        }
    }
    return inputContext;
}
 
Example #30
Source File: Window.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the input context for this window. A window always has an input context,
 * which is shared by subcomponents unless they create and set their own.
 * @see Component#getInputContext
 * @since 1.2
 */
public InputContext getInputContext() {
    synchronized (inputContextLock) {
        if (inputContext == null) {
            inputContext = InputContext.getInstance();
        }
    }
    return inputContext;
}