當前位置: 首頁>>代碼示例>>Java>>正文


Java UnsupportedFlavorException.printStackTrace方法代碼示例

本文整理匯總了Java中java.awt.datatransfer.UnsupportedFlavorException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java UnsupportedFlavorException.printStackTrace方法的具體用法?Java UnsupportedFlavorException.printStackTrace怎麽用?Java UnsupportedFlavorException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.datatransfer.UnsupportedFlavorException的用法示例。


在下文中一共展示了UnsupportedFlavorException.printStackTrace方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: importData

import java.awt.datatransfer.UnsupportedFlavorException; //導入方法依賴的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


注:本文中的java.awt.datatransfer.UnsupportedFlavorException.printStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。