-
Bug
-
Resolution: Fixed
-
P3
-
5.0, 6, 6u2
-
b25
-
x86
-
linux, linux_2.6
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2155995 | 6u10 | Oleg Sukhodolsky | P3 | Resolved | Fixed | b09 |
FULL PRODUCT VERSION :
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) Server VM (build 1.6.0_02-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux thinkpad-x60 2.6.20-16-generic #2 SMP Fri Aug 31 00:55:27 UTC 2007 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Copy an image to the clipboard (using DataFlavor.imageFlavor). Paste the image into a Java application that takes images from the clipboard. It works fine. Paste into OpenOffice or the Gimp. Nothing is pasted.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the program below. Then try to paste into OpenOffice.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An image of a red square should be pasted into OpenOffice.
ACTUAL -
Nothing is pasted.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.image.*;
import javax.swing.*;
/**
* This program demonstrates the transfer of images between a Java application and the system
* clipboard.
* @version 1.22 2007-08-16
* @author Cay Horstmann
*/
public class ImageTransferTest2
{
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
JFrame frame = new JFrame();
frame.setSize(100, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
Graphics g = image.getGraphics();
g.setColor(Color.RED);
g.fillRect(25, 25, 50, 50);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
ImageSelection selection = new ImageSelection(image);
clipboard.setContents(selection, null);
}
});
}
}
class ImageSelection implements Transferable
{
/**
* Constructs the selection.
* @param image an image
*/
public ImageSelection(Image image)
{
theImage = image;
}
public DataFlavor[] getTransferDataFlavors()
{
return new DataFlavor[] { DataFlavor.imageFlavor };
}
public boolean isDataFlavorSupported(DataFlavor flavor)
{
return flavor.equals(DataFlavor.imageFlavor);
}
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException
{
if (flavor.equals(DataFlavor.imageFlavor))
{
return theImage;
}
else
{
throw new UnsupportedFlavorException(flavor);
}
}
private Image theImage;
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Run Windows.
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) Server VM (build 1.6.0_02-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux thinkpad-x60 2.6.20-16-generic #2 SMP Fri Aug 31 00:55:27 UTC 2007 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Copy an image to the clipboard (using DataFlavor.imageFlavor). Paste the image into a Java application that takes images from the clipboard. It works fine. Paste into OpenOffice or the Gimp. Nothing is pasted.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the program below. Then try to paste into OpenOffice.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An image of a red square should be pasted into OpenOffice.
ACTUAL -
Nothing is pasted.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.image.*;
import javax.swing.*;
/**
* This program demonstrates the transfer of images between a Java application and the system
* clipboard.
* @version 1.22 2007-08-16
* @author Cay Horstmann
*/
public class ImageTransferTest2
{
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
JFrame frame = new JFrame();
frame.setSize(100, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
Graphics g = image.getGraphics();
g.setColor(Color.RED);
g.fillRect(25, 25, 50, 50);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
ImageSelection selection = new ImageSelection(image);
clipboard.setContents(selection, null);
}
});
}
}
class ImageSelection implements Transferable
{
/**
* Constructs the selection.
* @param image an image
*/
public ImageSelection(Image image)
{
theImage = image;
}
public DataFlavor[] getTransferDataFlavors()
{
return new DataFlavor[] { DataFlavor.imageFlavor };
}
public boolean isDataFlavorSupported(DataFlavor flavor)
{
return flavor.equals(DataFlavor.imageFlavor);
}
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException
{
if (flavor.equals(DataFlavor.imageFlavor))
{
return theImage;
}
else
{
throw new UnsupportedFlavorException(flavor);
}
}
private Image theImage;
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Run Windows.
- backported by
-
JDK-2155995 Linux: Cannot copy image from Java to OpenOffice
- Resolved
- duplicates
-
JDK-6584971 Problem with clipboard paste in JDK 6 update 2 on Linux
- Closed
-
JDK-6641340 Java ClipBorad is not compatible with GNOME.
- Closed
-
JDK-6676067 Copy/paste don't work with the right button of the mouse in GTK system
- Closed