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