Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

help: paste from clipboard

2 views
Skip to first unread message

John J

unread,
Oct 25, 2001, 12:31:29 PM10/25/01
to
does any one know how to do a paste from clipboard to a JTextPane....

any pointers would be greatly appteciated

thanks


Fridjof Jansen

unread,
Oct 25, 2001, 1:50:19 PM10/25/01
to
Just use JTextPane.paste();
And to copy, use JTextPane.copy();
There both methods of JTextComponent.


Fridjof.
"John J" <quattr...@yahoo.com> wrote in message
news:B7XB7.342758$j65.89...@news4.rdc1.on.home.com...

John J

unread,
Oct 25, 2001, 12:57:58 PM10/25/01
to
I tried this but nothing happends...

"Fridjof Jansen" <fri...@fridjof.nl> wrote in message
news:#OFS5RXX...@net037s.hetnet.nl...

John J

unread,
Oct 25, 2001, 4:04:20 PM10/25/01
to
Ok it does worlk but only if I copy from the java applet..
I need to paste from the system clipboard.

thanks


"Fridjof Jansen" <fri...@fridjof.nl> wrote in message
news:#OFS5RXX...@net037s.hetnet.nl...

Fridjof Jansen

unread,
Oct 25, 2001, 6:56:31 PM10/25/01
to
Then perhaps something else is wrong in the code. If you could send us some
code?

Fridjof

"John J" <quattr...@yahoo.com> wrote in message

news:qwXB7.342932$j65.89...@news4.rdc1.on.home.com...

John J

unread,
Oct 25, 2001, 6:59:32 PM10/25/01
to
I am trying to get a paste working in a small applet,
I need to just be able to paste some text, but when I do this:

public void doPaste1() {
Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable content = cb.getContents(this);
try {
String s = (String) content.getTransferData(DataFlavor.stringFlavor);
myPaste(s); // my function that inserts text into a JTextPane at
last user position
} catch (Throwable e) { System.err.println(e); }
}

=========
the system tels me:
java.security.AccessControlException: access denied (java.awt.AWTPermission
accessClipboard)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkSystemClipboardAccess(Unknown Source)
at sun.awt.windows.WToolkit.getSystemClipboard(Unknown Source)
at myjapplet.doPaste(myjapplet.java:442)
==========

any help on how to fix this would be greatly greatly appreciated.

thanks


"Fridjof Jansen" <fri...@fridjof.nl> wrote in message

news:uh0KO9Z...@net005s.hetnet.nl...

Fridjof Jansen

unread,
Oct 25, 2001, 8:13:11 PM10/25/01
to
I think an applet can't access the system clipboard. This makes sense, cause
otherwise
everyone on the web could read your clipboard.

Sorry for not thinking of this before

Fridjof
"John J" <quattr...@yahoo.com> wrote in message

news:oP0C7.345953$j65.90...@news4.rdc1.on.home.com...

John J

unread,
Oct 25, 2001, 7:13:20 PM10/25/01
to
I kind of understand that but in the Applet, a TextArea accepts all text
input from Ctrl+V....

thanks

"Fridjof Jansen" <fri...@fridjof.nl> wrote in message

news:#bKS2naX...@net005s.hetnet.nl...

Paul Lutus

unread,
Oct 25, 2001, 7:16:11 PM10/25/01
to
"John J" <quattr...@yahoo.com> wrote in message
news:oP0C7.345953$j65.90...@news4.rdc1.on.home.com...

> I am trying to get a paste working in a small applet,
> I need to just be able to paste some text, but when I do this:
>
> public void doPaste1() {
> Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
> Transferable content = cb.getContents(this);
> try {
> String s = (String)
content.getTransferData(DataFlavor.stringFlavor);
> myPaste(s); // my function that inserts text into a JTextPane at
> last user position
> } catch (Throwable e) { System.err.println(e); }
> }
>
> =========
> the system tels me:
> java.security.AccessControlException: access denied
(java.awt.AWTPermission
> accessClipboard)

You cannot access the system clipboard from an applet. That is what the
message is telling you. Write an application (easy) or sign your applet (not
easy).

--
Paul Lutus
www.arachnoid.com


John J

unread,
Oct 25, 2001, 7:30:08 PM10/25/01
to
What is "Sign your applet" ? I never herd about it ...

thanks

"Paul Lutus" <nos...@nosite.zzz> wrote in message
news:%21C7.170612$%B.121...@bin1.nnrp.aus1.giganews.com...

Paul Lutus

unread,
Oct 25, 2001, 7:40:11 PM10/25/01
to
"John J" <quattr...@yahoo.com> wrote in message
news:4g1C7.346108$j65.90...@news4.rdc1.on.home.com...

> What is "Sign your applet" ? I never herd about it ...

It is a way to get the visitor to be offered a decision about whether they
trust you enough to allow your applet to function as an application on their
system. It is not easy to set up.

--
Paul Lutus
www.arachnoid.com


Paul Lutus

unread,
Oct 25, 2001, 7:40:58 PM10/25/01
to
"John J" <quattr...@yahoo.com> wrote in message
news:k01C7.346024$j65.90...@news4.rdc1.on.home.com...

> I kind of understand that but in the Applet, a TextArea accepts all text
> input from Ctrl+V....

Not if it is living in an applet.

--
Paul Lutus
www.arachnoid.com


Paul Murray

unread,
Oct 26, 2001, 11:41:39 AM10/26/01
to
"John J" <quattr...@yahoo.com> wrote in message
news:oP0C7.345953$j65.90...@news4.rdc1.on.home.com...

> I am trying to get a paste working in a small applet,
> I need to just be able to paste some text, but when I do this:

Won't work. I don't want your unsecured applet reading what is in my system
clipboard and sending it to you, so java won't let your applet do that.

__________________________________________________
Spot the difference!
Jer 48:10 A curse on him who is lax in doing the Lord's work! A curse on him
who keeps his sword from bloodshed!
Mk 16:16 He that believeth and is baptized shall be saved; but he that
believeth not shall be damned.
Quran 2 And kill them wherever you find them, ... if they do fight you, then
slay them; such is the recompense of the unbelievers.
http://www.users.bigpond.com/pmurray .

0 new messages