pasting images from excel with transparency have a black background

D

daddyb_1

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){}
}
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top