diff options
author | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2005-11-13 20:18:41 +0000 |
---|---|---|
committer | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2005-11-13 20:18:41 +0000 |
commit | 2c9e15cd1e6331f6465162a4f5263a4546b33dbc (patch) | |
tree | 5986190d22f38a470df275ebb152206361ef0175 | |
parent | e4952b6ae5a8c7db58c5ef6b3abe5266dd509e46 (diff) | |
download | classpath-2c9e15cd1e6331f6465162a4f5263a4546b33dbc.tar.gz |
2005-11-13 Audrius Meskauskas <AudriusA@Bioinformatics.org>
PR 24733
* javax/swing/TransferHandler.java (getClipboard): Rewritten.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | javax/swing/TransferHandler.java | 52 |
2 files changed, 35 insertions, 22 deletions
@@ -1,3 +1,8 @@ +2005-11-13 Audrius Meskauskas <AudriusA@Bioinformatics.org> + + PR 24733 + * javax/swing/TransferHandler.java (getClipboard): Rewritten. + 2005-11-13 Wolfgang Baer <WBaer@gmx.de> * javax/print/attribute/HashDocAttributeSet.java, diff --git a/javax/swing/TransferHandler.java b/javax/swing/TransferHandler.java index 73479f5c8..4828fdbfa 100644 --- a/javax/swing/TransferHandler.java +++ b/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; + } + } } } |