aspose file tools*
The moose likes Mac OS and the fly likes problem while pasting images on to the java application from Mac Systemclipboard Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "problem while pasting images on to the java application from Mac Systemclipboard" Watch "problem while pasting images on to the java application from Mac Systemclipboard" New topic
Author

problem while pasting images on to the java application from Mac Systemclipboard

kalpana s
Greenhorn

Joined: Dec 22, 2003
Posts: 8
hi all,

i am creating a photouploader tool for Mac . i am using using java1.4.2 on Mac OS x.

i have a problem while pasting images on to the java application from Mac Systemclipboard

i am able to copy only one image file from the system clipboard and paste it on the java application. ie., the jList.

if i copy more than one image file into the system clipboard, the paste operation does not work.

i have this problem only when i run the application on mac os.
On windows i am able to paste any number of images on to the java application - it works fine!!!

i need help on this ... The code portion for the 'paste' operaton is below
=================================================================
1. Toolkit kit = Toolkit.getDefaultToolkit();
2. final Clipboard clipboard = kit.getSystemClipboard();
3. Transferable tr = clipboard.getContents(clipboard);
4. try{
5. java.util.List fileList = (java.util.List)tr.getTransferData(DataFlavor.javaFileListFlavor);
6. Iterator iterator = fileList.iterator();
7. while (iterator.hasNext())
8. {
9. File file = (File)iterator.next();
10. ((DefaultListModel)jList.getModel()).addElement(new JLabel(getImage(file)));
11. }
12. } catch(UnsupportedFlavorException no){ no.printStackTrace();}
13. catch(IOException io){io.printStackTrace();}
=================================================================
i get the following exception at line 4.. when i tried to paste 3 .gif files �and works for one gif file

java.awt.datatransfer.UnsupportedFlavorException: application/x-java-file-list
� � � � at sun.awt.datatransfer.ClipboardTransferable.getTransferData(ClipboardTransferable.java:168)
� � � � at UploadPhotosPane.pasteActionPerformed(UploadPhotosPane.java:778)
� � � � at UploadPhotosPane$19.actionPerformed(UploadPhotosPane.java:553)



any help on this is highly appreciated,
its urgents also

Thanks in advance
kalpana
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

"psk",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

P.S. Claiming that your post is "urgent" is a good way to get it ignored. I'd edit that part out were I you.
kalpana s
Greenhorn

Joined: Dec 22, 2003
Posts: 8
hi bear,

i have changed my display name as per your suggestion and reposting the same question again

------------------------------------------------------------------------
i am creating a photouploader tool for Mac . i am using using java1.4.2 on Mac OS x.

i have a problem while pasting images on to the java application from Mac Systemclipboard

i am able to copy only one image file from the system clipboard and paste it on the java application. ie., the jList.

if i copy more than one image file into the system clipboard, the paste operation does not work.

i have this problem only when i run the application on mac os.
On windows i am able to paste any number of images on to the java application - it works fine!!!

i need help on this ... The code portion for the 'paste' operaton is below
=================================================================
1. Toolkit kit = Toolkit.getDefaultToolkit();
2. final Clipboard clipboard = kit.getSystemClipboard();
3. Transferable tr = clipboard.getContents(clipboard);
4. try{
5. java.util.List fileList = (java.util.List)tr.getTransferData(DataFlavor.javaFileListFlavor);
6. Iterator iterator = fileList.iterator();
7. while (iterator.hasNext())
8. {
9. File file = (File)iterator.next();
10. ((DefaultListModel)jList.getModel()).addElement(new JLabel(getImage(file)));
11. }
12. } catch(UnsupportedFlavorException no){ no.printStackTrace();}
13. catch(IOException io){io.printStackTrace();}
=================================================================
i get the following exception at line 4.. when i tried to paste 3 .gif files and works for one gif file

java.awt.datatransfer.UnsupportedFlavorException: application/x-java-file-list
at sun.awt.datatransfer.ClipboardTransferable.getTransferData(ClipboardTransferable.java:168)
at UploadPhotosPane.pasteActionPerformed(UploadPhotosPane.java:778)
at UploadPhotosPane$19.actionPerformed(UploadPhotosPane.java:553)



any help on this is highly appreciated,

Thanks in advance
kalpana
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

"kalpana",

Apparently you missed this part:

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.


thanks,
bear
aruna makhija
Greenhorn

Joined: Dec 07, 2000
Posts: 17
[Post removed. Any discussion of the naming policy should take place in the JavaRanch forum. -- Bear]
[ July 29, 2004: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem while pasting images on to the java application from Mac Systemclipboard