summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAudrius Meskauskas <audriusa@Bioinformatics.org>2005-11-13 20:18:41 +0000
committerAudrius Meskauskas <audriusa@Bioinformatics.org>2005-11-13 20:18:41 +0000
commit2c9e15cd1e6331f6465162a4f5263a4546b33dbc (patch)
tree5986190d22f38a470df275ebb152206361ef0175
parente4952b6ae5a8c7db58c5ef6b3abe5266dd509e46 (diff)
downloadclasspath-2c9e15cd1e6331f6465162a4f5263a4546b33dbc.tar.gz
2005-11-13 Audrius Meskauskas <AudriusA@Bioinformatics.org>
PR 24733 * javax/swing/TransferHandler.java (getClipboard): Rewritten.
-rw-r--r--ChangeLog5
-rw-r--r--javax/swing/TransferHandler.java52
2 files changed, 35 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 3d448cdc3..e460a4e7d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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;
+ }
+ }
}
}