-
Bug
-
Resolution: Not an Issue
-
P3
-
7u6, 8
-
os_x
FULL PRODUCT VERSION :
java version " 1.7.0_40-ea "
Java(TM) SE Runtime Environment (build 1.7.0_40-ea-b28)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b47, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Mac OS X 10.7.5
A DESCRIPTION OF THE PROBLEM :
Images copied in the clipboard by a system application can't be retrieved in the JRE, and images copied in the clipboard by the JRE can't be pasted in a system application, like Preview.
REGRESSION. Last worked in version 6u45
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the test case included in this report.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When I copy an image in Preview, I expected that the second message dialog box would display " Image available in clipboard " .
When the 3rd last message dialog box is displayed, I expected I could open in Preview or paste in other application a 100x100 pixels black image.
ACTUAL -
The second message dialog box displayed " No image in clipboard " .
After the 3rd last message dialog box, I couldn't paste an image in an other application.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Toolkit;
import java.awt.datatransfer.*;
import java.awt.image.BufferedImage;
import javax.swing.JOptionPane;
public class ClipboardImageFlavorTest {
public static void main(String [] args) {
JOptionPane.showMessageDialog(null,
" Copy into clipboard a text or an image then click on OK " );
showClipboardStatus();
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
new Transferable() {
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor.equals(DataFlavor.stringFlavor)
|| flavor.equals(DataFlavor.imageFlavor);
}
public DataFlavor [] getTransferDataFlavors() {
return new DataFlavor [] {DataFlavor.stringFlavor,
DataFlavor.imageFlavor};
}
public Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException {
if (flavor.equals(DataFlavor.stringFlavor)) {
return " String copied from Java into clipboard " ;
} else if (flavor.equals(DataFlavor.imageFlavor)) {
return new BufferedImage(100, 100,
BufferedImage.TYPE_INT_RGB);
} else {
throw new UnsupportedFlavorException(flavor);
}
}
}, null);
showClipboardStatus();
}
private static void showClipboardStatus() {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
boolean stringAvailable =
clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor);
boolean imageAvailable =
clipboard.isDataFlavorAvailable(DataFlavor.imageFlavor);
JOptionPane.showMessageDialog(null,
" <html> " + (stringAvailable ? " String available in clipboard "
: " No string in clipboard " )
+ " <br> " + (imageAvailable ? " Image available in clipboard "
: " No image in clipboard " ));
}
}
---------- END SOURCE ----------
java version " 1.7.0_40-ea "
Java(TM) SE Runtime Environment (build 1.7.0_40-ea-b28)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b47, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Mac OS X 10.7.5
A DESCRIPTION OF THE PROBLEM :
Images copied in the clipboard by a system application can't be retrieved in the JRE, and images copied in the clipboard by the JRE can't be pasted in a system application, like Preview.
REGRESSION. Last worked in version 6u45
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the test case included in this report.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When I copy an image in Preview, I expected that the second message dialog box would display " Image available in clipboard " .
When the 3rd last message dialog box is displayed, I expected I could open in Preview or paste in other application a 100x100 pixels black image.
ACTUAL -
The second message dialog box displayed " No image in clipboard " .
After the 3rd last message dialog box, I couldn't paste an image in an other application.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Toolkit;
import java.awt.datatransfer.*;
import java.awt.image.BufferedImage;
import javax.swing.JOptionPane;
public class ClipboardImageFlavorTest {
public static void main(String [] args) {
JOptionPane.showMessageDialog(null,
" Copy into clipboard a text or an image then click on OK " );
showClipboardStatus();
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
new Transferable() {
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor.equals(DataFlavor.stringFlavor)
|| flavor.equals(DataFlavor.imageFlavor);
}
public DataFlavor [] getTransferDataFlavors() {
return new DataFlavor [] {DataFlavor.stringFlavor,
DataFlavor.imageFlavor};
}
public Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException {
if (flavor.equals(DataFlavor.stringFlavor)) {
return " String copied from Java into clipboard " ;
} else if (flavor.equals(DataFlavor.imageFlavor)) {
return new BufferedImage(100, 100,
BufferedImage.TYPE_INT_RGB);
} else {
throw new UnsupportedFlavorException(flavor);
}
}
}, null);
showClipboardStatus();
}
private static void showClipboardStatus() {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
boolean stringAvailable =
clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor);
boolean imageAvailable =
clipboard.isDataFlavorAvailable(DataFlavor.imageFlavor);
JOptionPane.showMessageDialog(null,
" <html> " + (stringAvailable ? " String available in clipboard "
: " No string in clipboard " )
+ " <br> " + (imageAvailable ? " Image available in clipboard "
: " No image in clipboard " ));
}
}
---------- END SOURCE ----------