1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-23 11:29:06 +00:00

Fix copy to clipboard on Mac.

The previous code `Toolkit.getDefaultToolkit().createImage()` does not read the image file into memory but Clipboard.setContents() on Mac seems to need an image that is already in memory.
This commit is contained in:
matthew16550 2021-09-08 14:51:40 +10:00
parent ce95fff0fa
commit 9e7db1ce64

View File

@ -388,10 +388,14 @@ class ImageWindow extends JFrame {
if (generatedImage == null) { if (generatedImage == null) {
return; return;
} }
try {
final File png = generatedImage.getPngFile(); final File png = generatedImage.getPngFile();
final Image image = Toolkit.getDefaultToolkit().createImage(png.getAbsolutePath()); final Image image = ImageIO.read(png);
final ImageSelection imgSel = new ImageSelection(image); final ImageSelection imgSel = new ImageSelection(image);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(imgSel, null); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(imgSel, null);
} catch (IOException e) {
e.printStackTrace();
}
} }
public SimpleLine getSimpleLine() { public SimpleLine getSimpleLine() {