JDK-4201563 : Can only get Plain Text or Unicode String data flavours from native clipboard
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-01-08
  • Updated: 2001-01-21
  • Resolved: 2001-01-21
Related Reports
Duplicate :  
Description

Name: dbT83986			Date: 01/07/99


OS: 95 and NT

Using the following code suggests that JDK1.2 provides trransferable support for RTF and HTML formats:

		FlavorMap flavorMap = SystemFlavorMap.getDefaultFlavorMap();
		Map map = flavorMap.getFlavorsForNatives(null);
		Set keys = map.keySet();
		Iterator keysIterator = keys.iterator();
		while(keysIterator.hasNext())
		{
			Object key = keysIterator.next();
			Object value = map.get(key);
			System.out.println("Key: '" + key + "'; Value: '" + value + "'");
		}


However I seem unable to transfer HTML or RTF data from the  native clipboard (I've pasted data from FrontPage and Word 97 into the clipboard). I've used the following code to establish what data flavours are available:

	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource() == pasteB)
		{
			Transferable clipboardData = clipboard.getContents(this);
			String text = null;
			try
			{
				DataFlavor[] flavors = clipboardData.getTransferDataFlavors();
				for(int i = 0; i < flavors.length; i++)
				{
					String mime = flavors[i].getMimeType();
					String name = flavors[i].getHumanPresentableName();
					System.out.println("Mime: '" + mime + "'; Name: '" + name + "'");
				}
				text = (String)(clipboardData.getTransferData(DataFlavor.stringFlavor));
			}
			catch(Exception ex)
			{
				text = ex.toString();
			}
			textArea.append("\n" + text);
		}
	}
	
The printout when I run the above indicates that only Plain Text and Unicode String types are available.

Thanks,

--Jonathan Allin
(Review ID: 49003)
======================================================================