Pasting Image  from Mac clipboard to Java Based Application.

Hi,
I am working on "iMac 10.2.7". I need to paste an image from other
application using "Java version 1.4.1". I am trying to retrieve the image
from the system clipboard after it is copied from some other application. I
am pasting the code which illustrates my requirement. It works fine on
windows. But does not work on Mac.
On Mac it does not cross the supported data flavor check
(clipData.isDataFlavorSupported(DataFlavor.imageFlavor) where clipData is
the Transferable object). It seems Mac has some InputStream instead of Image
in the clipboard when some image is copied. I tried to read that InputStream
using ImageIO.read(java.io.InputStream). But that is also returning null.
Thanks
Santanu
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
import javax.swing.*;
public class ClipboardTest extends JFrame implements KeyListener{
     JLabel label;
     static Toolkit kit = null;
     static Clipboard clipboard = null;
     public static void main (String arg[]) {
          kit = Toolkit.getDefaultToolkit();
          clipboard = kit.getSystemClipboard();
          JLabel l = new JLabel();
          JButton button = new JButton("Paste from clipboard");
          final ClipboardTest ct = new ClipboardTest(l);
          ct.getContentPane().add(l,BorderLayout.CENTER);
          ct.getContentPane().add(button,BorderLayout.SOUTH);
          ct.setVisible(true);
     button.addActionListener(
          new ActionListener() {
               public void actionPerformed(ActionEvent ae) {
                    pasteImage(ct.label);
     button.addKeyListener(ct);
     public ClipboardTest (JLabel l) {
          label = l;
     public static void pasteImage(JComponent jComp) {
               jComp.setTransferHandler(new ImageSelection());
               TransferHandler handler = jComp.getTransferHandler();
               Transferable clipData = clipboard.getContents(null);
          if (clipData != null) {
          if (clipData.isDataFlavorSupported(DataFlavor.imageFlavor)) {
               handler.importData(jComp, clipData);
     //Key listener methods
     public void keyPressed(KeyEvent e) {
     int c = e.getKeyCode();
     if (c == 86) {
          if (e.isControlDown()) {
               pasteImage(label);
     public void keyReleased(KeyEvent e) {}
     public void keyTyped(KeyEvent e) {}
class ImageSelection extends TransferHandler implements Transferable {
     /* DataFlavor instance that holds imageflavor value*/
     private static final DataFlavor flavors[] = {DataFlavor.imageFlavor};
     private Image image;
     public boolean importData(JComponent comp, Transferable transferable) {
     try {
     if (transferable.isDataFlavorSupported(flavors[0])) {
     image = (Image)transferable.getTransferData(flavors[0]);
               if (comp instanceof JLabel) {
               ((JLabel)comp).setIcon(new ImageIcon(image));
               comp.repaint();
               return true;
     } catch (Exception ignored) {
          ignored.printStackTrace();
     return false;
     // Transferable Interface methods
     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(flavors[0]);

Here are two commercial options:
JTwain + JSane
http://asprise.com/product/jtwain/index.php
Morena
http://www.gnome.sk/Twain/jtp.html
Haven't tested them, so don't no how good they are, nor how easy they are to use on multiple platforms.

Similar Messages

  • ActionScript 3 paste image from clipboard

    Is it possible to paste image from clipboard using ActionScript 3 and Flash Player 11?
    Need web solution only, not AIR.
    Use case:
    - User opens image some in some native image editor.
    - Selects part of image and clicks Ctrl+C (Command+C on Mac). Now part of image is in clipboard.
    - User open web application that is running in Flash Player
    - User inputs image by clicking Ctrl+V (Command+V on Mac) or using context Menu->Paste.
    I browsed the docs for Clipboard at: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/Clipboard .html
    The only format that seems reasonable would be Clipboard.getData(BITMAP_FORMAT) on paste events. This seems to be supported by AIR only.
    Are there any ways to implement the given use case with Flash Player?
    Thanks!
    P.S.: There is some support of paste events in HTML in Chrome and Firefox, but Internet Explorer 10 and Apple Saffari 6 seems still have issues with pure-HTML approach.
    Cheers,
    Ignat.

    This seems to be supported by AIR only.
    What gives you the impression?
    AIR-only functions are marked with a fancy AIR logo
    (like the first one in this list: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/images/sprite-index.png )
    and getData doesn`t have it, so it should work without problems in the "normal" Flash Player if you follow the recepy:
    Note for Flash Player applications: In Flash Player 10, a paste operation from the clipboard first requires a user event (such as a keyboard shortcut for the Paste command or a mouse click on the Paste command in a context menu). Clipboard.getData() will return the contents of the clipboard only if the InteractiveObject has received and is acting on a paste event. Calling Clipboard.getData() under any other circumstances will be unsuccessful.

  • Copy/Paste Image from Clipboard - still no support for transparency?

    I just tried to load an Image from the Clipboard by using DataFlavor.imageFlavor. Everything works well if the clipboard-image doesn´t use any transparency. When loading an image with alpha-channel (png or gif), the transparency occurs as black pixels. Here is the code snippet:
    Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();;
    Transferable t = clip.getContents(null);
    BufferedImage img = (BufferedImage) t.getTransferData(DataFlavor.imageFlavor);img.getType allways returns TYPE_INT_RGB, even if the image contains alpha-data.
    According to this Bug-Report
    [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4720930]
    this should have bin fixed in 1.4.2, if i´m not wrong?
    Can anyone confirm this problem, and is there any workaround? The one described in the bug-report doesn´t work for me, since clipboard-images in my case don´t match DataFlavor.javaFileListFlavor.

    The best is to try it yourself I guess.
    Go to Github and try pasting an image into the compose editor.
    The editor definitely supports image pastings. They work directly in Chrome(ium).
    Thus I am wondering why Firefox does not support direct pasting from clipboard into the editor.
    See the attached screenshot regarding the editor I am talking about.

  • Convert EPS images from Mac to PC

    I wonder if anyone have any experience of converting large
    quantities of images from Mac to PC? I have several thousands of
    freehand eps-images saved for Mac that I need to convert to a
    PC-eps. Anyone know any application that can accomplish
    this?

    Eyden wrote:
    > I have several thousands of freehand eps-images saved
    for Mac that I need to
    > convert to a PC-eps. Anyone know any application that
    can accomplish this?
    Do the EPS files contain live text? Fonts could be an issue
    unless you are
    doing the conversion on a PC and replacing fonts as you go.
    The only other
    difference between Mac and PC EPS files is the preview. If
    you don't need
    the PC preview, you may not need to do the conversion at all.
    FH cannot open (as editable) many flavors of EPS file, but
    can import an EPS
    and export it as QuarkXPress EPS which contains both Mac and
    PC previews. I
    don't know about the quality of the PC preview in this case,
    as it would be
    based on the Mac preview, not the original Postscript data.
    If you're on a
    Mac, you could possibly use an Applescript to open and export
    the EPS files.
    The task would be simpler and more reliable using
    Illustrator, which has a
    Postscript interpreter and is scriptable.
    Judy Arndt

  • Very slow pasting data from the Clipboard into a Sharepoint 365 list by using the Quick Edit view

    <p>In sharepoint 2010 it was very fast to paste data from the Clipboard by using the Data Sheet view. Why is it so slow in Sharepoint 365 when using the Quick Edit View? is there a workaround?</p><p>also in Sharepoint 365 if you try to
    paste a large number of records (2,000) it will freeze.</p>

    I'm interest about same thing. Clipboard is often only way to migrate lists between sharepoint versions and now it is almost unpossible to use.

  • I used to be able to copy and paste images from the internet into keynote slides and pages. Now when I copy and paste all I get is an empty  box. My iskysoft iTube studio has also stopped downloading videos. Is there an extension I need to enable?

    I used to be able to copy and paste images from the internet into keynote slides and pages. Now when I copy and paste all I get is an empty  box. My iskysoft iTube studio has also stopped downloading videos. Is there an extension I need to enable? Any ideas

    Try dragging the image to the desktop, then drag the image to the slide you want it on

  • Copy and paste image from IE to Illustrator

    Dear Illustrator users,
    I need to copy and paste images from IE10 or IE11 (Internet Explorer) to Illustrator (CS6, CC).
    I right-click image, choose "copy" in Internet Explorer
    now I can paste it to mspaint, word, photoshop, etc. It works fine..
    but when I try to paste image to Illustrator, it pastes url link instead of image.
    I know this problem comes with IE10. When I downgrade to IE9, it start to work fine.
    Any suggestion?
    Kind Regards,
    Jarda

    Hi Jacob,
    Thank you for a quick answer. Your suggestion is correct, but saving image to a file is an additional step.
    Since I do this task "thousands a day", this is unacceptable
    Any other suggestion?
    Regards,
    Jarda

  • Cut and Paste images from flash to power point

    Can you cut and paste images from flash player to power point?
    Thanks!

    Are the settings for the two Sequences completely indentical?
    -DH

  • Pasting tables from Mac TextEdit to InDesign CS4

    Hi,
    The thread title says it all, really.
    Can you paste tables from Mac's TextEdit to InDesign CS4?

    Pasting table content will paste as tabbed text. You can place (cmd+d) RTF (not RTFD) and maintain tables.
    You will lose custom strokes and a few other formatting elements, but overall placing tables will preserve the integrity of them as you find them in text edit.

  • Front End for BW 3.5 and Java based application

    We are trying to connect two systems; SAP based (through BW) and Non-SAP based (Sybase, Java based) applications. We are exploring BI Java SDK with UDDI or XI services to bring Non-SAP data to NetWeaver. We don't want to store all data from sybase to BW. We could use Front end of BW or any other GUI from SAP Portal. I have heard options like UI, GUI machine, net weaver developer studio, visual composer. Ideally, we would like to combine non-sap and sap data in Business explorer/BW web browser but any other front end suggestion within Net weaver frame work will help us keep our cost down. Please advise.
    Thanks.
    Vinay Karna

    We're in the middle of upgrading from 3.1 SP 22 BW w/6.20 SAPGUI. We've only upgraded a sandbox BW server at this point, but we have upgraded all BW team members with SAPGUI 6.40 FEP 5 and can successfully connect to our 3.5 and 3.1 BWs.

  • Problem with Java-based application and WebVPN

    Hello. Could you please help me in find out any specification/known limitations in using Java-based applications through WebVPN in Cisco ASA 5520 v8.3(2).
    A customer of mine has got in trouble in using a Java viewer for graphical files that is invoked by another application (this one correctly served via WebVPN), that cannot be launched because JVM does not find it (NullPointer).
    Our suspects are generically about the URL rewriting of the WebVPN and/or unsupported configuration in the ASA SSL certificates vs Java.
    Any hint about where to search or what to try?
    Thanks.

    Hello. Could you please help me in find out any specification/known limitations in using Java-based applications through WebVPN in Cisco ASA 5520 v8.3(2).
    A customer of mine has got in trouble in using a Java viewer for graphical files that is invoked by another application (this one correctly served via WebVPN), that cannot be launched because JVM does not find it (NullPointer).
    Our suspects are generically about the URL rewriting of the WebVPN and/or unsupported configuration in the ASA SSL certificates vs Java.
    Any hint about where to search or what to try?
    Thanks.

  • Embedding java based application in  portal

    hi ,
    I want to embedd a java based application..Iam giving the pageURL in provider file..will it work r any problem..
    i want to display that application as portlet.is mentioning page url is enough..that is tomcat..
    Second way:if i copy all jsps and source files to htdocs and create a war file and ear file..will it works..
    how to mention in provider.xml file to show this application in portal.
    is there any specific way..
    plz mail me
    regards,

    Our expirience with these types of applications is that you will need to integrate your jsp files (to some degree) into Oracle's jpdk framework, which essentially means some of the functionality of your jsp files may not work properly unless you switch to use many of JSP files with the JPDK api (i.e. custom tags and custom api calls so that the portal can render your application as a java portlet provider).
    I think there is also a way that you can deploy your web application in oc4j and possibly use the web clipping portlet to show this java based application, however, I am not familiar with this, and you should probably ask Oracle Support for more information
    Regards,
    Jack
    Check out Compoze Portlets for Oracle9iAS Portal v2.0 featuring portlets for discussion, chat, whiteboard and seamless integration with Domino / Exchange at http://www.compoze.com. Download them for a free trial!

  • Webdynpro Java based application performance testin

    Hi Experts,
    could any one of you please provide me step by step guide to use some tool which can be used for profiling webdynpro java based application?
    this is very urgent...... kindly help
    Best regards
    Falgun

    My recommendations:
    - Always use a BufferedInputStream and BufferedOutputStream around the socket streams
    - Increase the socket send and receive buffers to at least 32k if you are on a Windows platform where the default is a ridiculous 8k, which hasn't been enough for about 15 years.
    - Your 2-second timeout is far too short. Increase it to at least 10 seconds.
    - Your strategy of counting up to N short timeouts of S seconds each is completely pointless. Change it to one single timeout of N*S seconds. There is nothing to be gained by the complication you have introduced to this.

  • What is better way to install java based application?

    What installer is better to create stanalone installer package for my java based application?

    InstallShield Multi-Platform Edition or Install Anywhere are equally good. They are not cheap though.

  • Dragging a single image from mac Preview to InDesign CS6 doesn't work but 2 or more images does?

    I usually take anywhere form 2500 to 5000 photos in any single day's session. Because of this, I need an easy way to sort through them and grab just the one's I need to import to my InDesign "book". I have been using CS3 for years now, and what I always did was open up Preview on my Mac to browse all my days photos. Then when I found a good one, I would simply drag that single image over to my opened InDesign screen and just drop it into a page. I would then go back to Preview and continue this procedure until I had looked through all the days images. I could even drag multiple images over and once I was over InDesign I can just click each image and pop them into various pages with ease. Then I upgraded to CS6 and I've hit a kink in the works. When I drag over a single image to InDesign, before I drop it into the page my mouse pointer looks like 3 tiny paste images (the little rectangle with the folded down upper left corner). If I release my mouse to drop the image into InDesign, it just flys back to Preview and doesn't drop into InDesign. Now if I get 2 or more images from Preview, this process works just like it always did. But 1 single image... never. I've tried holding down command, shift, control, option, and combos of those buttons to see if anything changes and it never does. I always get the mouse icon with 3 little paste icons. In CS3 if I dragged a single image it would only show 1 paste icon and 3 icons if I dragged 2 or more, but not in CS6. Is there a setting I'm missing or a preference? I've tried looking through everything that I can find to no avail. There has to be a way??? Thanks!

    Use Bridge instead
    good luck

Maybe you are looking for