pasting images from excel with transparency have a black background

Discussion in 'Java' started by daddyb_1@yahoo.com, Aug 21, 2006.

  1. Guest

    Hi There,

    I've searched on this topic, but have only found an unanswered post
    from 2003. Basically, if I copy a chart from excel (well, from a
    number of vector based packages it seems) that has transparency, the
    resulting image in java has had the transparency replaced with black.

    However, if you paste the chart into word, select it and then copy it,
    it will paste into java with no problems.

    I've searched the java bug database, but have had not luck.

    To repeat this, simply create a chart in excel, set it's background to
    fill:none and copy the chart. Then run the class below and press the
    button.

    I am running Office 2002 and using Sun JDK 1.5.07

    Any help much appreciated on this as it's driving me nuts.

    Thanks,
    Brian

    =============================================================
    import java.awt.*;
    import java.awt.datatransfer.*;
    import java.awt.event.*;

    import javax.swing.*;

    public class ClipboardTest
    {
    public static void main(String[] args)
    {
    try
    {
    JFrame frame = new JFrame();
    frame.setLayout(new BorderLayout());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JLabel label = new JLabel();
    label.setPreferredSize(new Dimension(200, 200));
    frame.add(label, BorderLayout.CENTER);
    JButton button = new JButton("Get Clipboard");
    button.addActionListener(new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    try
    {
    Transferable xfer =
    Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
    label.setIcon(new
    ImageIcon((Image)xfer.getTransferData(DataFlavor.imageFlavor)));
    }
    catch (Exception ex) {}
    }
    });
    frame.add(button, BorderLayout.SOUTH);
    frame.pack();
    frame.setVisible(true);
    }
    catch (Exception e){}
    }
    }
    , Aug 21, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Z2FuZXNoX2luZm9zeXM=?=

    pasting xml data into an excel template

    =?Utf-8?B?Z2FuZXNoX2luZm9zeXM=?=, Aug 24, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    674
  2. Ron Vecchi
    Replies:
    1
    Views:
    384
  3. Chris Harris

    CSS background transparency

    Chris Harris, Jul 10, 2003, in forum: HTML
    Replies:
    10
    Views:
    56,265
    Nicolai P. Zwar
    Jul 14, 2003
  4. King Coffee

    Background Transparency

    King Coffee, Oct 18, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    611
    Alexey Smirnov
    Oct 18, 2009
  5. Mr. x

    pasting images on paintbrush

    Mr. x, Nov 16, 2003, in forum: Javascript
    Replies:
    1
    Views:
    113
Loading...

Share This Page