Is there a trick to pasting GIF file or is this a bug?

I am using 1.4.2 and the following little program is lifted from one of the TechTip articles ( http://developer.java.sun.com/developer/JDCTechTips/2003/tt0318.html#1 ) for illustration purposes.
The problem is that GIF image pasted from the system clipboard is completely distorted... (it doesn't matter whether the image is originally copied to the clipboard from MS Paint or Adobe PhotoShop).
Here is a link to what I'm talking about:
http://home.comcast.net/~viravan/Capture.png
here is the code:
DrawImage.java
import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
import javax.swing.*;
public class DragImage {
   public static void main(String args[])  {
      JFrame frame = new JFrame("Drag Image");
      frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);
      Container contentPane = frame.getContentPane();
      final Clipboard clipboard = frame.getToolkit().getSystemClipboard();
      final JLabel label = new JLabel();
      if (args.length > 0)  {
         Icon icon = new ImageIcon(args[0]);
         label.setIcon(icon);
      label.setTransferHandler(new ImageSelection());
      MouseListener mouseListener = new MouseAdapter()  {
         public void mousePressed(MouseEvent e)  {
            JComponent comp = (JComponent) e.getSource();
            TransferHandler handler = comp.getTransferHandler();
            handler.exportAsDrag( comp, e, TransferHandler.COPY);
      label.addMouseListener(mouseListener);
      JScrollPane pane = new JScrollPane(label);
      contentPane.add(pane, BorderLayout.CENTER);
      JButton copy = new JButton("Copy");
      copy.addActionListener(new ActionListener()  {
         public void actionPerformed(ActionEvent e)  {  
            Action copyAction = TransferHandler.getCopyAction();
            copyAction.actionPerformed( new ActionEvent( label, ActionEvent.ACTION_PERFORMED, (String) copyAction.getValue(Action.NAME), EventQueue.getMostRecentEventTime(), 0));
      JButton clear = new JButton("Clear");
      clear.addActionListener(new ActionListener()  {
         public void actionPerformed( ActionEvent actionEvent)  {
            label.setIcon(null);
      JButton paste = new JButton("Paste");
      paste.addActionListener(new ActionListener()  {
         public void actionPerformed( ActionEvent actionEvent)  {  
            Action pasteAction = TransferHandler.getPasteAction();
            pasteAction.actionPerformed( new ActionEvent(label, ActionEvent.ACTION_PERFORMED, (String) pasteAction.getValue(Action.NAME), EventQueue.getMostRecentEventTime(), 0));
      JPanel p = new JPanel();
      p.add(copy);
      p.add(clear);
      p.add(paste);
      contentPane.add(p, BorderLayout.SOUTH);
      frame.setSize(300, 300);
      frame.show();
}ImageSelection.java
import java.awt.*;
import java.awt.image.*;
import java.awt.datatransfer.*;
import java.io.*;
import javax.swing.*;
public class ImageSelection extends TransferHandler {
   private static final DataFlavor flavors[] = {
      DataFlavor.imageFlavor
   public int getSourceActions(JComponent c)  {
      return TransferHandler.COPY;
   public boolean canImport( JComponent comp, DataFlavor flavor[])  {
      if (!(comp instanceof JLabel)) {
         return false;
      for (int i=0, n=flavor.length;i<n;i++) {
         for (int j=0, m=flavors.length;j<m;j++) {
            if (flavor.equals(flavors[j])) {
return true;
return false;
public Transferable createTransferable( JComponent comp) {
if (comp instanceof JLabel) {
JLabel label = (JLabel) comp;
Icon icon = label.getIcon();
if (icon instanceof ImageIcon) {
final Image image = ((ImageIcon) icon).getImage();
final JLabel source = label;
Transferable transferable = new Transferable() {
public Object getTransferData( DataFlavor flavor) {
if (isDataFlavorSupported(flavor)) {
return image;
return null;
public DataFlavor[] getTransferDataFlavors() {
return flavors;
public boolean isDataFlavorSupported( DataFlavor flavor) {
return flavor.equals( DataFlavor.imageFlavor);
return transferable;
return null;
public boolean importData( JComponent comp, Transferable t) {
if (comp instanceof JLabel) {
JLabel label = (JLabel) comp;
if (t.isDataFlavorSupported(flavors[0])) {
try {
Image image = (Image) t.getTransferData(flavors[0]);
ImageIcon icon = new ImageIcon(image);
label.setIcon(icon);
return true;
} catch (UnsupportedFlavorException ignored) {
} catch (IOException ignored) {
return false;
Note that pasting .JPG or .PNG files with the same program works fine!
;o)
V.V.

Just to make sure I understood you, I copied gifs from IE to the clipboard and then used your program to paste them into your app. Right??? Here are the steps for MS-Paint:
1) activate MS Paint,
2) load a small gif file (any file will do)
3) CTRL-A to select the file in MS-Paint, CTRL-C to copy to clipboard
4) activate the java program
5) click the paste button in the java program
Here are the steps in PhotoShop:
1) activate PhotoShop
2) load a GIF file
3) CTRL A to select the entire image or use the tool to select a smaller area and CTRL-C to copy to clipboard
4 & 5 are same as above
V.V.

Similar Messages

  • Gif files

    Is there away to view animated gif files from photobucket.com or something on the iPod touch

    you may have to load them from dmsBase to view them.

  • How can one edit a .gif file graphics background and change the fonts in Photoshop Elements 13?

    I am trying to change the color and fonts of some of my web sites .gif files. Can I change the color to another hexadecimal color and change the fonts of the letters in Photoshop 13? I am using Windows 7 and heard that you could save the .gif file to another format, edit it, then change the file back to a .gif file. Is this true? If so, how do you do it? The file just has a solid color with the letters "Firm " on it. No animation.

    You can edit a gif without changing the format, but once you save the file as a gif the text becomes part of the image, not text anymore, so you would need to clone or heal away the existing text and then create a new text layer and use save for web to create a new gif.
    For access to the most editing tools, while the file is open in the editor go to image>mode and change it from index color to RGB. Saving as a gif will change it back to index mode.

  • Gif file now rendered

    The attached gif file is not rendered in ADE. It is one of several hundred gif files in a chapter, and only one other gif file has the same problem. All others are rendered as expected. Which property of the gif file could cause this behaviour?
    Simon

    The attached epub book contains three gif files. Gif file si64.gif is not rendered in my ADE. The paragraph is repeated twice, once with the div elements around the gif files, and once without any div element. In both paragraphs the problem is present.
    The screenshot shows a rendering of the xhtml file in firefox, with si64.gif.
    Simon

  • Anyone knows if there's a way to share files between ipads wihtout using the itunes software?

    I've been trying with some apps to do this but there's always a prior step in which you have to drag the files to the app using ITUNES. Someone knows if there's a way to share files without using this program?

    Every file has to be associated with an app. So you can't avoid that. You could look into something like dropbox, where you access the info online, and I believe, download it via the dropbox app then 'send' it to the app that'll read/open it.

  • Is there support for animated .gif files?

    Is there support for animated gif files using
    form builder? I can't get it to work.
    Thanks
    Sean
    I am using forms 6.0

    She used the Link Tool, specfied 'Image URL' as the Source File Format and the url of the animated GIF in the Source Filename. Hope that helps.
    Makes sense but the form is not for the web.
    I have looked at doing it with timers and switching canvases, but that is just too much
    for sloppy animation. It's just not tight enough.
    Thanks,
    Sean
    null

  • Bridge CS6 crashing when there is a GIF file in the folder.

    Out of the box, Adobe Bridge has been crashing "randomly" when opening folders.
    To pinpoint the cause of the crash, I created a new folder and dragged the files one by one from one of the other folders that crashed Bridge.
    It all works fin until I drag a GIF file, then it just stops responding and crashes immediately.
    I have tried with several different GIF files, and they all seem to crash Bridge.
    Any ideas of any settings to stop this from happening?
    I, of course, need to work with gifs, so filtering those out is not a solution.
    Thanks!

    THanks for your answer,
    It seems to be any gif causing the crash, at least I haven't found one that doesn't crash it so far, here's an example:
    It doesn't have to be animated either. Still gifs crash it too.
    I'm using Windows 7 Enterprise, Service Pack 1, 64-bit OS, 24Gb RAM, Intel Core i7 CPU, I have a GeForce GTX 590 video card. I have a similar setup at my home office, and bridge seems to work just fine there (with the same files even).
    I searched around here and I found issues popping up with Bridge and GIFs, but nothing answered or exactly like my problem. Weird.
    Is there a way for Bridge to not try to render GIFs, but still show them so I can change metadata, open them in PS, etc?

  • Iconic buttons in design time ... Is there any way to take their icons from the jar or at least from gif files?

    I've put my button icons in a signed gif, and they work fine at runtime.
    The problem is at design time, I can't get to see their icons properly.
    I have to convert the gifs to ico and place them in a folder referenced by the old UI_ICON registry variable.
    Also, as the gifs are 16x16, they are cropped in design time, because I see them as if they where stretched to 32x32 size.
    At least it would be enough if I could place the gifs directly somewhere, without converting to ico.
    It seems as if oracle had not put any development work in the builder, which is like a direct port from the 6i c/s version.

    Since you didn't mention exactly which Forms version you are using, I will guess and assume it is one of the many versions after 6.0.8.  The Forms Builder 9.x+ supports ico, jpg, and gif files.  It will not however read them from a jar.  Therefore, you will need to extract them into a directory as defined by UI_ICON.  Also, the files will need to be of the same type (gif, jpg, ico).  Mixing formats is not recommended or supported.  The format you choose can be defined in UI_ICON_EXTENSION
    So for example in your Registry you might have something like this:
    UI_ICON = C:\myImagesDirectory
    UI_ICON_EXTENSION = gif
    Since "gif" is the default, you do not need to set this if using "gif" files.

  • Animated .gif files in mail. Problem persists. (PANTHER)

    3-17-07
    Happy St. Valentine's Day to all you Irish folks!
    I'm posting this even though there are threads in the forum that I have
    used and contributed to in the past on this topic.
    The problem PERSISTS!
    The problem/situation is that in mail from family/trusted friends, after I
    open the mail, there is no "Load Images" warning at the top but an
    animated .gif file is in the message! (don't get me wrong, i do sincerely
    love dancing bears. i just want some warning.)
    Any suggerstions?
    In mail preferences,viewing I have unchecked "display images and embedded
    objects in HTML messages".
    In mail preferences,junkmail I have "enable junk mail filtering" and
    "trust junk mail headers..." both checked.
    All junk mail is flagged as junk. (in junkmail,advanced and in rules).
    I keep the preview pane collapsed.
    I pay attention to flags and don't open junk from strangers.
    eMac G4 (build 7W98) 125 GHz, 256 MB, 37 GB   Mac OS X (10.3.9)   dialup 56K modem

    just cleaning up my junk

  • .gif files no longer working when I send them through text

    Hello,
    I've been sending and receiving animated .gif files through Messages on my iphone for a long time without issue. However the last month or so the ones I send no longer animate. They still work if I view them through safari on my desktop computer so I know the files are not corrupted. The ones that people send me through Messages still work on my phone. But if I send one through text/imessage it's just a static image.
    Anyone have any idea what could be going on or how to fix it?
    Much Appreicated

    No, that's definitely not it.  I subscribe to several newspapers, and the online versions are meant to be printed and saved.  Even when I find an offered up PDF version, it does not matter whether I save it or print it to PDF, it is not being recognized as text. When I do run OCR, it comes out very, very poor quality, which is not the case with scanned items and such.
    I am currently getting by with copy/pasting to a word document, and then saving to PDF from there, for some reason this method IS working as usual.  It does take considerably more time to do, however.
    I'm still very confused at what could have changed in the past several days!

  • Is there a trick or tip for envelopes?

    Is there a trick or tip for envelopes?
    In Word it was easy to print an envelope. You were able to set up your preference for return address & font & a different font for the outgoing address & save it. Then when finished typing a letter you could highlight the outgoing address, copy it & go to Tools/Letters & mailings/Envelopes & mailings & you got a separate window with your previously set fonts & return address. All you had to do was paste your outgoing address in the address field & then you were ready to print the envelope. This was very useful & FAST as you need not save a separate file with the address. Especially if you didn’t plan on more letters to that address.
    I cannot figure out how to do something similar in Pages. The best I can come up with is slow & many steps. I must open a new FROM TEMPLATE CHOOSER Pages window from the file menu, select a particular envelope, get a new window & type in all the address information including my return address selection; fonts, size, etc. Then that Envelope file can be used to print an envelope & you now have a separate file to save.
    There MUST be an easier way. I finally created a template titled “aaaaaaa envelope template” & put in my return address in the font & size I wanted. I also typed a sample outgoing address in the (larger) font I often use for envelopes.
    Now when I finish a letter I copy the outgoing address, I locate & open my “aaaaaaa envelope template” file & highlight the sample address & paste my desired outgoing address from the letter I just typed. Next, I must “save as”in order to both keep the new file & save my template. This cannot be the best way to do this. I know many Mac people type many letters (I don’t) & this would drive them crazy or to buy Word (ugh).
    Suggestions?

    Well, I guess there is NOT some obvious tip or trick I missed. I am already using a template I created. From my original post:
    “I finally created a template titled “aaaaaaa envelope template” & put in my return address in the font & size I wanted. I also typed a sample outgoing address in the (larger) font I often use for envelopes.
    Now when I finish a letter I copy the outgoing address, I locate & open my “aaaaaaa envelope template” file & highlight the sample address & paste my desired outgoing address from the letter I just typed.”
    I don’t do that many envelopes or letters, maybe a few per month. I don’t put street addresses in my address book just email addresses. (I think I’ll add street addresses)
    Thanks Walt, I D/L Easy Envelope Widget. I’ll play around with it soon. I actually do not have my actual name listed on my address book the entry is titled “Me” (Not sure why, perhaps just an unneeded security habit) so that is what appears in the return address for Easy Envelope & I doubt that can be manually changed/saved as per the FAQ. I like the idea of printing the postal bar code to speed things up though.

  • Unable to access gif files from the server

    hi all,
    i have successfully signed an applet and it is loading in the client system also. in that applet, i instantiated a jbutton as given below:
    JButton jb = new JButton(new ImageIcon("http://192.168.91.154:8080/success/set.gif"));
    but the icon din appear and a blank button appears, even when accessed from the server system.
    if i give the exact path like c:/blazix/webfiles/success/ set.gif, the icon is coming in the server system but not in other systems. i tried without port no also but in vain. pl solve my problem. what i need is how to
    specify the path of the file[any file] which is present in server.
    or if i put all the gif files in the jar file, can i access the gif files present in the jar file [set for archive] ? if i can, give me the soln for accessing the gif file present in the jar file, so that i need not access the server to get the gif files.(i.e) how to specify the path of the gif files present in the jar file?
    i ve one more doubt. the jni library file shld be in the server, and the client has to access the library in the server. i think the applet loaded in the client ll search for the library in the local m/c only . how to make the applet to search for library in the server??
    i feel only by using rmi we can solve this problem. am i correct? if so i feel that an appln or applet running in the server shld access the jni library, and the applet in the client side should communicate with this server appln using rmi to get the data.is it correct? is there
    anyother way?
    i appreciate your help in this regard. thanks in advance. bye, padmanbhan.

    Better information on what you are doing with JNI might help you get an answer.
    If you have some server process that needs to use JNI, then I would code a servlet to call, instead of using RMI to ge there.
    Depending on your environment, and the target audiences environment, RMI may just cause you a lot of grief. Firewalls etc, get in the way of RMI connections and force security holes to be opened in order to work.
    If you use a servlet, then traffic to your server process is done via standard http calls, which will already be enabled, because your app runs in a browser.
    If ther data requirements are heavy duty, your server could always send an XML stream to the client, which would allow you to describe complex data to the client.
    Running JNI stuff from the client directly means a lot of local infrastructure to run your app. The code you want to run, the JNI library ....
    If what you have is really an application, but want the convenience of starting it from a browser, look at Java WebStart. Then you can distribute an application via the browser, and WebStart will worry about the deployment issues for you.
    In Summary:
    Stay away from RMI from applets if you can help it.
    If you really have an App, then try WebStart to manage the distribution issues for you.

  • Animated Gif files in Captivate

    I have created an animated GIF file in Photoshop that i want to use in my captivate file.
    The file wont preview in any of the preview modes other than the HTML5 output preview. All other previews just show the first frame of the GIF file.
    If i chose to SWAP the animation with another GIF from the library the preview shows the animation playing.. see attached
    Is there something im doing wrong here.
    I guess i could upload my final file to the LMS with HTML5 output as this preview shows the animation but i also read there are limitations with this output as some transitions / effects dont work.
    Any help would be greatly appreciated.
    Thanks
    Darren

    Hi Darren,
    Yes, you can verify whether your GIF would fucntion correctly on HTML5 platform by Window--HTML5 Tracker Pod.
    I am not an expert on Photoshop, but still would like to make a recommendation.
    Set the 'delay' value for each of your Frame to 0.01 or some value if it shows as 0, this can be done using the animation frame Window. Save it as GIF again for Web Devices and import in Captivate, see, if you are abale to preview this time.
    Thanks,
    Anjaneai

  • Can Premiere Elements be used on an animated gif file?

    I am considering purchasing Premiere Elements but I need to know if one can use it to add effects to an animated gif file.
    For example, in Photoshop Elements one can add certain effects to a gif image, such as giving it certain textures or filters.
    Can one do the same kind of thing in Premiere Elements and if so can it be done to an animated gif file?
    Maybe a better way to ask this question is:  can you import an animated gif file into Premiere Elements and then manipulate it?  Run filters, etc.
    Thanks for your help.

    If you load your GIF into Premiere Elements 10, edit it, then share to an AVI file, you can then import the AVI file into GIF Movie Gear by Gamani, which will then create an animated GIF. I learned about this utility from a Microsoft tutorial on creating icons for Windows XP.
    http://www.gamani.com/product_icon.htm
    If you use Firefox and get redirected, try using Internet Explorer instead.
    After the trial period is over, it's $29.95US for 4 licences.
    When you share to an AVI file, you will want to select the Microsoft AVI item from the list, then click the advanced button to open up the dialog where you will need to select a codec and enter the frame size and frame rate. The codec will have to be one that GIF Movie Gear likes, so there may be some trial and error needed to get a good codec. I shared to an AVI after picking Xvid for the codec, which GIF Movie Gear imported.

  • Gif files not moving

    Aloha all, can anyone tell me what program I need to make animated gif files animate? When I download any animated gif files they don't move. When I open in Preview all pics are there, they just don't play. Any advice on how to make them move like they should? mahalo for any tips info. JB

    Apart from Safari there are many free viewers which do show animated gifs.
    CocoviewX is just one of them.

Maybe you are looking for

  • I have Photoshop for the IPad and my file won't load, can anyone help?

    I have the iOS app for adobe Photoshop and I stopped working on my project for a bit, went back to access it (I did save before hand) and it won't load, the loading animation is all that shows and nothing else. It's been doing this for 30 minutes or

  • Reconstruction of request in BI 7.0

    hi All,   In 3.5 , i can go to "Reconstruct" tab in the cube and able to select the request which need to be reconstructed. But in 7.0, is there any way to reconstruct the request like what we used to do in 3.5. Can you please let me know how we shou

  • APPEND cl_gui_frontend_services  file_save_dialog

    Hi, with old functions DOWNLOAD it was possible to append a file to an existing, how can I do this using method file_save_dialog of the class cl_gui_frontend_services? Please help me! Thanks Lara

  • Safari 4.0.3, Snow Leopard, and PDFs

    For some reason I can no longer view .PDF files in Safari after installing Snow Leopard. It worked before, under Leopard. Acrobat 8 works. Reader 9 works. Preview works. But I can't view .PDFs in Safari, and if I attempt to save them so that I could

  • I can't drag/drop files!! HELP :( :(

    I can't drag/drop files from one place to another, like across my desktop,i have to cut/copy paste them into another location. It randomly change as before i could drag/ drop files, etc