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


Java DataFlavor.stringFlavor方法代码示例

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


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

示例1: clipboardCopy

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@Override
public Transferable clipboardCopy() throws IOException {
    Transferable deflt = super.clipboardCopy();
    ExTransferable enriched = ExTransferable.create(deflt);
    ExTransferable.Single ex = new ExTransferable.Single(DataFlavor.stringFlavor) {
        @Override
        protected Object getData() {
            return "<dependency>\n" + //NOI18N
                    "  <groupId>" + record.getGroupId() + "</groupId>\n" + //NOI18N
                    "  <artifactId>" + record.getArtifactId() + "</artifactId>\n" + //NOI18N
                    "  <version>" + record.getVersion() + "</version>\n" + //NOI18N
                    "</dependency>"; //NOI18N
        }
    };
    enriched.put(ex);
    return enriched;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:VersionNode.java

示例2: testCanDrop

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
public void testCanDrop() throws ClassNotFoundException {
    DefaultExternalDropHandler handler = new DefaultExternalDropHandler();

    DataFlavor[] flavors = new DataFlavor[] { DataFlavor.imageFlavor };
    assertFalse( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { DataFlavor.imageFlavor, DataFlavor.stringFlavor };
    assertFalse( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { DataFlavor.javaFileListFlavor };
    assertTrue( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { DataFlavor.javaFileListFlavor, DataFlavor.imageFlavor };
    assertTrue( handler.canDrop( flavors ) );

    DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");

    flavors = new DataFlavor[] { uriListFlavor };
    assertTrue( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { uriListFlavor, DataFlavor.imageFlavor };
    assertTrue( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { uriListFlavor, DataFlavor.javaFileListFlavor, DataFlavor.imageFlavor };
    assertTrue( handler.canDrop( flavors ) );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:DefaultExternalDropHandlerTest.java

示例3: setDataFlavor

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/**
 * Sets and returns the type of the Transferable object of the clipboard
 * 
 * @param t - Transferable object in clipboard
 *            
 * @return t'type - Type of DataFlavor
 */
public static DataFlavor setDataFlavor(Transferable t) {
	DataFlavor[] flavors = t.getTransferDataFlavors();

	for (int i = 0; i < flavors.length; i++) {

		if (flavors[i].equals(DataFlavor.stringFlavor)) {
			type = Contents.TYPE_STRING;
			return DataFlavor.stringFlavor;
		} else if (flavors[i].equals(DataFlavor.imageFlavor)) {
			type = Contents.TYPE_IMAGE;
			return DataFlavor.imageFlavor;
		} else if (flavors[i].equals(DataFlavor.javaFileListFlavor)) {
			type = Contents.TYPE_FILE;
			return DataFlavor.javaFileListFlavor;
		} else {
		}
	}
	return null;
}
 
开发者ID:Team-Sprout,项目名称:Clipcon-Client,代码行数:27,代码来源:ClipboardController.java

示例4: getTransferData

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
	if (flavor == binaryFlavor) {
		return this;
	} else if (flavor == DataFlavor.stringFlavor) {
		StringBuilder buf = new StringBuilder();
		for (int i = 0; i < headers.length; i++) {
			buf.append(headers[i]);
			buf.append(i == headers.length - 1 ? '\n' : '\t');
		}
		for (int i = 0; i < contents.length; i++) {
			for (int j = 0; j < contents[i].length; j++) {
				buf.append(contents[i][j]);
				buf.append(j == contents[i].length - 1 ? '\n' : '\t');
			}
		}
		return buf.toString();
	} else {
		throw new UnsupportedFlavorException(flavor);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:TableTabClip.java

示例5: testGetFileList

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
public void testGetFileList() throws ClassNotFoundException, URISyntaxException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
    DefaultExternalDropHandler handler = new DefaultExternalDropHandler();
    DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");

    Transferable t = new TransferableImpl( new ArrayList(), new DataFlavor[] { DataFlavor.imageFlavor, DataFlavor.stringFlavor } );
    assertNull( handler.getFileList( t ) );

    List<File> list = new ArrayList<File>( 2 );
    list.add( new File("//somedir/somefile.someext") );
    list.add( new File("c:\\somedir\\somefile.someext") );
    t = new TransferableImpl( list, new DataFlavor[] { DataFlavor.javaFileListFlavor, DataFlavor.stringFlavor } );

    List<File> extractedList = handler.getFileList( t );
    assertNotNull( extractedList );
    assertEquals( 2, extractedList.size() );
    for( Iterator i=list.iterator(); i.hasNext(); ) {
        assertTrue( extractedList.contains( i.next() ) );
    }

    String uriList = "file:///somedir/somefile.someext\r\nfile:/c:/somedir/somefile.someext";
    t = new TransferableImpl( uriList, new DataFlavor[] { uriListFlavor, DataFlavor.stringFlavor } );
    extractedList = handler.getFileList( t );
    assertNotNull( extractedList );
    assertEquals( 2, extractedList.size() );
    assertTrue( extractedList.contains( new File( new URI("file:///somedir/somefile.someext") ) ) );
    assertTrue( extractedList.contains( new File( new URI("file:/c:/somedir/somefile.someext") ) ) );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:DefaultExternalDropHandlerTest.java

示例6: testIsDataFlavorSupported

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@Test
public void testIsDataFlavorSupported() {
	assertTrue(tkre
			.isDataFlavorSupported(TransferableKernelRepositoryEntry.entryFlavour));
	DataFlavor d = DataFlavor.stringFlavor;
	assertFalse(tkre.isDataFlavorSupported(d));
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:8,代码来源:TransferableKernelRepositoryEntryTest.java

示例7: retrieveDataFlavor

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
public static DataFlavor retrieveDataFlavor(){
    DataFlavor df=DataFlavor.stringFlavor;
    try {
        FileInputStream istream = new FileInputStream("t.tmp");
        ObjectInputStream p = new ObjectInputStream(istream);
        df.readExternal(p);
        istream.close();
    } catch (Exception ex){
        throw new RuntimeException("FAIL: problem occured while retrieving DataFlavor");
    }

    return df;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ExternalizeTest.java

示例8: getTransferData

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
	if (flavor == binaryFlavor) {
		return data;
	} else if (flavor == DataFlavor.stringFlavor) {
		int bits = 1;
		for (int i = 0; i < data.length; i++) {
			int k = data[i] >> bits;
			while (k != 0 && bits < 32) {
				bits++;
				k >>= 1;
			}
		}

		int chars = (bits + 3) / 4;
		StringBuilder buf = new StringBuilder();
		for (int i = 0; i < data.length; i++) {
			if (i > 0) {
				buf.append(i % 8 == 0 ? '\n' : ' ');
			}
			String s = Integer.toHexString(data[i]);
			while (s.length() < chars)
				s = "0" + s;
			buf.append(s);
		}
		return buf.toString();
	} else {
		throw new UnsupportedFlavorException(flavor);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:31,代码来源:Clip.java

示例9: ElementStringTransferable

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/** Construct new Transferable for this node. */
ElementStringTransferable() { super(DataFlavor.stringFlavor); }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:3,代码来源:DBElementNode.java

示例10: getTransferDataFlavors

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@Override
public DataFlavor[] getTransferDataFlavors() {
	return new DataFlavor[] { DataFlavor.stringFlavor };
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:5,代码来源:TransferHandlerAnnotationPlaintext.java

示例11: getTransferDataFlavors

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@Override
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[]{DataFlavor.stringFlavor};
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:MissingEventsOnModalDialogTest.java

示例12: getTransferDataFlavors

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@Override
public DataFlavor[] getTransferDataFlavors() {
	return new DataFlavor[] { binaryFlavor, DataFlavor.stringFlavor };
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:5,代码来源:TableTabClip.java

示例13: isDataFlavorSupported

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
	return flavor == binaryFlavor || flavor == DataFlavor.stringFlavor;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:5,代码来源:TableTabClip.java

示例14: string

import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/**
 * String data flavor
 * 
 * @return DataFlavor
 */
public static DataFlavor string() {
    return DataFlavor.stringFlavor;
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:9,代码来源:DataFlavors.java


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