diff options
Diffstat (limited to 'libjava/classpath/javax/swing/TransferHandler.java')
-rw-r--r-- | libjava/classpath/javax/swing/TransferHandler.java | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/libjava/classpath/javax/swing/TransferHandler.java b/libjava/classpath/javax/swing/TransferHandler.java index 96cb9d42abf..4828fdbfa98 100644 --- a/libjava/classpath/javax/swing/TransferHandler.java +++ b/libjava/classpath/javax/swing/TransferHandler.java @@ -75,30 +75,38 @@ public class TransferHandler implements Serializable } } + /** + * Get the system cliboard. If not available, create and return the VM-local + * clipboard. + * + * @param component a component, used to get the toolkit. + * @return the clipboard + */ private static Clipboard getClipboard(JComponent component) { - SecurityManager sm = System.getSecurityManager(); - - if (sm != null) - { - try - { - sm.checkSystemClipboardAccess(); - - // We may access system clipboard. - return component.getToolkit().getSystemClipboard(); - } - catch (SecurityException e) - { - // We may not access system clipboard. - } - } - - // Create VM-local clipboard if non exists yet. - if (clipboard == null) - clipboard = new Clipboard("Clipboard"); - - return clipboard; + // Avoid throwing exception if the system clipboard access failed + // in the past. + if (clipboard != null) + return clipboard; + else + { + try + { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + sm.checkSystemClipboardAccess(); + + // We may access system clipboard. + return component.getToolkit().getSystemClipboard(); + } + catch (Exception e) + { + // We may not access system clipboard. + // Create VM-local clipboard if none exists yet. + clipboard = new Clipboard("Clipboard"); + return clipboard; + } + } } } @@ -162,15 +170,18 @@ public class TransferHandler implements Serializable } public void exportAsDrag (JComponent c, InputEvent e, int action) - { + { + // TODO: Implement this properly } protected void exportDone (JComponent c, Transferable data, int action) { + // TODO: Implement this properly } public void exportToClipboard(JComponent c, Clipboard clip, int action) { + // TODO: Implement this properly } public int getSourceActions (JComponent c) |