本文整理匯總了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;
}