Problem accessing Windows clipboard  
Author Message
Fred





PostPosted: 2005-8-5 23:44:00 Top

java-programmer, Problem accessing Windows clipboard Hi

In my java program I have a class which contains some code which accesses
the Windows clipboard.

When I use this class in a standalone application (JFrame) I can retrieve
data from the clipboard no problem.

When I use this very same class in a JApplet which I run in Internet
Explorer, I cannot get the data from the Windows clipboard.

The line of code that my JApplet gets hung up on is ...

Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();

This line of code does execute properly when executed in the standalone
application.

My class does contain the line: import java.awt.datatransfer.*;

I am using the following page from the Java Developer's Almanac as a
reference.

http://javaalmanac.com/egs/java.awt.datatransfer/ToClip.html

is there a known issue with this sort of thing that I don't know about?

Hopefully I have provided enough information for you.

Thanks in advance.

Fred.


 
Andrew Thompson





PostPosted: 2005-8-6 0:21:00 Top

java-programmer >> Problem accessing Windows clipboard On Fri, 5 Aug 2005 11:43:56 -0400, Fred wrote:

> In my java program I have a class which contains some code which accesses
> the Windows clipboard.
...
> When I use this very same class in a JApplet which I run in Internet
> Explorer, I cannot get the data from the Windows clipboard.
>
> The line of code that my JApplet gets hung up on is ...

Maybe it needs counselling. [ ;-) ]

> Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();

..yep.

> is there a known issue with this sort of thing that I don't know about?

Depends how you define 'issue'. Your applet needs to
be signed to gain programmtaic access to the clipboard.

There are numerous references throughout this* document to
applets, as well as some references to security. Please
read it all, as I suspect you are also 'swallowing exceptions'.

* <http://www.physci.org/codes/javafaq.jsp>

HTH

--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Soon To Be A Major Religion
 
Fred





PostPosted: 2005-8-6 1:14:00 Top

java-programmer >> Problem accessing Windows clipboard
"Andrew Thompson" <email***@***.com> wrote in message
news:1h57bwy6v631m$.jgxg6xfmnzqt$email***@***.com...

<snip>

> Depends how you define 'issue'. Your applet needs to
> be signed to gain programmtaic access to the clipboard.

yep that seems to be it.

I am not an advanced programmer by any stretch of the imagnation, just a
hobbyist, and had given no consideration to signing.

After reading things over, it all seems rather complex, so I think this
idea, which is not at all critical, goes on the shelf for now, there are too
many other things that I need to learn how to do.

Thanks anyways

Fred.


 
 
Andrew Thompson





PostPosted: 2005-8-6 1:43:00 Top

java-programmer >> Problem accessing Windows clipboard On Fri, 5 Aug 2005 13:13:58 -0400, Fred wrote:

> "Andrew Thompson" <email***@***.com> wrote in message
> news:1h57bwy6v631m$.jgxg6xfmnzqt$email***@***.com...
>
> <snip>
>> Depends how you define 'issue'. Your applet needs to
>> be signed to gain programmtaic access to the clipboard.
>
> yep that seems to be it.
>
> I am not an advanced programmer by any stretch of the imagnation, just a
> hobbyist, and had given no consideration to signing.
>
> After reading things over, it all seems rather complex,

Signing your aplications and applets is not straightforward,
but can lead to very worthwhile results for some of the more
complicated things. But..

> ..so I think this
> idea, which is not at all critical, goes on the shelf for now,

Hold that thought*.

>.. there are too
> many other things that I need to learn how to do.

That is a sensible idea, leave the code *signing*
for a later time.

* But I think you can still offer the ability to copy
text, you just need to provide it in a TextArea and
instruct the user to ctrl-a (select all) and ctrl-c
(copy) the text.

Note that this behaviour will not work on *all* VM's,
so you better let the user know it is a 'maybe', but I
would hope it covers >90% of Java'd PC's.

--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Disclaimer: Any Resemblance To Actual Robots Would Be Really Cool