diff options
author | Julien Gouesse <[email protected]> | 2015-09-20 20:29:46 +0200 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2015-09-20 20:29:46 +0200 |
commit | bece393c28092ca2d7bb0e312c747193476e8fbf (patch) | |
tree | 4ac987853b9185b490d7ba14c7e8719d5d148def /ardor3d-awt | |
parent | c17c6772cdb8fd35b4fb245149297182239eb4fa (diff) |
Moves the only dependency on AWT in ardor3d-ui into ardor3d-awt
Diffstat (limited to 'ardor3d-awt')
-rw-r--r-- | ardor3d-awt/src/main/java/com/ardor3d/ui/text/awt/AwtCopyPasteImpl.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/ui/text/awt/AwtCopyPasteImpl.java b/ardor3d-awt/src/main/java/com/ardor3d/ui/text/awt/AwtCopyPasteImpl.java new file mode 100644 index 0000000..3b5ee4e --- /dev/null +++ b/ardor3d-awt/src/main/java/com/ardor3d/ui/text/awt/AwtCopyPasteImpl.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2008-2012 Ardor Labs, Inc. + * + * This file is part of Ardor3D. + * + * Ardor3D is free software: you can redistribute it and/or modify it + * under the terms of its license which may be found in the accompanying + * LICENSE file or at <http://www.ardor3d.com/LICENSE>. + */ + +package com.ardor3d.ui.text.awt; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; + +import com.ardor3d.ui.text.CopyPasteImpl; + +public class AwtCopyPasteImpl implements CopyPasteImpl { + + @Override + public String getClipBoardContents() { + final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + final Transferable clipboardContent = clipboard.getContents(null); + + if (clipboardContent != null && clipboardContent.isDataFlavorSupported(DataFlavor.stringFlavor)) { + try { + return (String) clipboardContent.getTransferData(DataFlavor.stringFlavor); + } catch (final Exception e) { + e.printStackTrace(); + } + } + return null; + } + + @Override + public void setClipBoardContents(final String contents) { + final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + final StringSelection string = new StringSelection(contents); + clipboard.setContents(string, null); + } +} |