protected DataFlavor getImportFlavor(DataFlavor[] flavors,
	 								JTextComponent c) {

		DataFlavor refFlavor = null;
		DataFlavor stringFlavor = null;
            
		for (int i = 0; i < flavors.length; i++) {

			String mime = flavors[i].getMimeType();
			if (mime.startsWith("text/plain")) {
				return flavors[i];
			}
			else if (refFlavor == null
				&& mime.startsWith("application/x-java-jvm-local-objectref")
				&& flavors[i].getRepresentationClass() == String.class)
			{
				refFlavor = flavors[i];
			}
			else if (stringFlavor==null &&
				flavors[i].equals(DataFlavor.stringFlavor))
			{
				stringFlavor = flavors[i];
			}

		}

		if (refFlavor != null)
			return refFlavor;
		else if (stringFlavor != null)
			return stringFlavor;

		return null;

	}