75 |
} |
} |
76 |
} |
} |
77 |
|
|
78 |
|
/** |
79 |
|
* Get the system cliboard. If not available, create and return the VM-local |
80 |
|
* clipboard. |
81 |
|
* |
82 |
|
* @param component a component, used to get the toolkit. |
83 |
|
* @return the clipboard |
84 |
|
*/ |
85 |
private static Clipboard getClipboard(JComponent component) |
private static Clipboard getClipboard(JComponent component) |
86 |
{ |
{ |
87 |
SecurityManager sm = System.getSecurityManager(); |
try |
88 |
|
{ |
89 |
if (sm != null) |
SecurityManager sm = System.getSecurityManager(); |
90 |
{ |
if (sm != null) |
91 |
try |
sm.checkSystemClipboardAccess(); |
|
{ |
|
|
sm.checkSystemClipboardAccess(); |
|
92 |
|
|
93 |
// We may access system clipboard. |
// We may access the system clipboard. |
94 |
return component.getToolkit().getSystemClipboard(); |
return component.getToolkit().getSystemClipboard(); |
95 |
} |
} |
96 |
catch (SecurityException e) |
catch (Exception e) |
97 |
{ |
{ |
98 |
// We may not access system clipboard. |
// We may not access system clipboard. |
99 |
} |
// Create VM-local clipboard if none exists yet. |
100 |
} |
if (clipboard == null) |
101 |
|
clipboard = new Clipboard("Clipboard"); |
102 |
// Create VM-local clipboard if non exists yet. |
return clipboard; |
103 |
if (clipboard == null) |
} |
|
clipboard = new Clipboard("Clipboard"); |
|
|
|
|
|
return clipboard; |
|
104 |
} |
} |
105 |
} |
} |
106 |
|
|