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


Java InputContext.endComposition方法代码示例

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


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

示例1: importData

import java.awt.im.InputContext; //导入方法依赖的package包/类
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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:JTextComponent.java

示例2: importData

import java.awt.im.InputContext; //导入方法依赖的package包/类
/**
 * This method causes a transfer to a component from a clipboard or a
 * DND drop operation.  The Transferable represents the data to be
 * imported into the component.
 *
 * @param comp  The component to receive the transfer.  This
 *  argument is provided to enable sharing of TransferHandlers by
 *  multiple components.
 * @param t The data to import
 * @return <code>true</code> iff the data was inserted into the component.
 */
@Override
public boolean importData(JComponent comp, Transferable t) {

	JTextComponent c = (JTextComponent)comp;
	withinSameComponent = c==exportComp;

	// if we are importing to the same component that we exported from
	// then don't actually do anything if the drop location is inside
	// the drag location and set shouldRemove to false so that exportDone
	// knows not to remove any data
	if (withinSameComponent && c.getCaretPosition()>=p0 && c.getCaretPosition()<=p1) {
		shouldRemove = false;
		return true;
	}

	boolean imported = false;
	DataFlavor importFlavor = getImportFlavor(t.getTransferDataFlavors(), c);
	if (importFlavor != null) {
		try {
			InputContext ic = c.getInputContext();
			if (ic != null) {
				ic.endComposition();
			}
			Reader r = importFlavor.getReaderForText(t);
			handleReaderImport(r, c);
			imported = true;
		} catch (UnsupportedFlavorException ufe) {
			ufe.printStackTrace();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
	}

	return imported;

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:48,代码来源:RTATextTransferHandler.java

示例3: processFocusEvent

import java.awt.im.InputContext; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:JFormattedTextField.java

示例4: importData

import java.awt.im.InputContext; //导入方法依赖的package包/类
/**
 * This method causes a transfer to a component from a clipboard or a 
 * DND drop operation.  The Transferable represents the data to be
 * imported into the component.  
 *
 * @param comp  The component to receive the transfer.  This
 *  argument is provided to enable sharing of TransferHandlers by
 *  multiple components.
 * @param t The data to import
 * @return <code>true</code> iff the data was inserted into the component.
 */
@Override
public boolean importData(JComponent comp, Transferable t) {

	JTextComponent c = (JTextComponent)comp;
	withinSameComponent = c==exportComp;

	// if we are importing to the same component that we exported from
	// then don't actually do anything if the drop location is inside
	// the drag location and set shouldRemove to false so that exportDone
	// knows not to remove any data
	if (withinSameComponent && c.getCaretPosition()>=p0 && c.getCaretPosition()<=p1) {
		shouldRemove = false;
		return true;
	}

	boolean imported = false;
	DataFlavor importFlavor = getImportFlavor(t.getTransferDataFlavors(), c);
	if (importFlavor != null) {
		try {
			InputContext ic = c.getInputContext();
			if (ic != null)
				ic.endComposition();
			Reader r = importFlavor.getReaderForText(t);
			handleReaderImport(r, c);
			imported = true;
		} catch (UnsupportedFlavorException ufe) {
			ufe.printStackTrace();
		} catch (BadLocationException ble) {
			ble.printStackTrace();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
	}

	return imported;

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:49,代码来源:RTATextTransferHandler.java

示例5: importData

import java.awt.im.InputContext; //导入方法依赖的package包/类
/**
 * This method causes a transfer to a component from a clipboard or a DND drop operation. The Transferable
 * represents the data to be imported into the component.
 * 
 * @param comp
 *            The component to receive the transfer. This argument is provided to enable sharing of TransferHandlers
 *            by multiple components.
 * @param t
 *            The data to import
 * @return <code>true</code> iff the data was inserted into the component.
 */
public boolean importData(JComponent comp, Transferable t) {

    JTextComponent c = (JTextComponent) comp;
    withinSameComponent = c == exportComp;

    // if we are importing to the same component that we exported from
    // then don't actually do anything if the drop location is inside
    // the drag location and set shouldRemove to false so that exportDone
    // knows not to remove any data
    if (withinSameComponent && c.getCaretPosition() >= p0 && c.getCaretPosition() <= p1) {
        shouldRemove = false;
        return true;
    }

    boolean imported = false;
    DataFlavor importFlavor = getImportFlavor(t.getTransferDataFlavors(), c);
    if (importFlavor != null) {
        try {
            InputContext ic = c.getInputContext();
            if (ic != null)
                ic.endComposition();
            Reader r = importFlavor.getReaderForText(t);
            handleReaderImport(r, c);
            imported = true;
        } catch (UnsupportedFlavorException ufe) {
            ufe.printStackTrace();
        } catch (BadLocationException ble) {
            ble.printStackTrace();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }

    return imported;

}
 
开发者ID:intuit,项目名称:Tank,代码行数:48,代码来源:RTATextTransferHandler.java

示例6: importData

import java.awt.im.InputContext; //导入方法依赖的package包/类
/**
 * This method causes a transfer to a component from a clipboard or a 
 * DND drop operation.  The Transferable represents the data to be
 * imported into the component.  
 *
 * @param comp  The component to receive the transfer.  This
 *  argument is provided to enable sharing of TransferHandlers by
 *  multiple components.
 * @param t The data to import
 * @return <code>true</code> iff the data was inserted into the component.
 */
public boolean importData(JComponent comp, Transferable t) {

	JTextComponent c = (JTextComponent)comp;
	withinSameComponent = c==exportComp;

	// if we are importing to the same component that we exported from
	// then don't actually do anything if the drop location is inside
	// the drag location and set shouldRemove to false so that exportDone
	// knows not to remove any data
	if (withinSameComponent && c.getCaretPosition()>=p0 && c.getCaretPosition()<=p1) {
		shouldRemove = false;
		return true;
	}

	boolean imported = false;
	DataFlavor importFlavor = getImportFlavor(t.getTransferDataFlavors(), c);
	if (importFlavor != null) {
		try {
			InputContext ic = c.getInputContext();
			if (ic != null)
				ic.endComposition();
			Reader r = importFlavor.getReaderForText(t);
			handleReaderImport(r, c);
			imported = true;
		} catch (UnsupportedFlavorException ufe) {
			ufe.printStackTrace();
		} catch (BadLocationException ble) {
			ble.printStackTrace();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
	}

	return imported;

}
 
开发者ID:Nanonid,项目名称:RSyntaxTextArea,代码行数:48,代码来源:RTATextTransferHandler.java


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