The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Java Help
|
Interact with System clipboard from applet.
Discuss Interact with System clipboard from applet. in the Java Help forum on Dev Shed. Interact with System clipboard from applet. Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 13th, 2006, 02:27 PM
|
 |
Wiser? Not exactly.
|
|
Join Date: May 2001
Location: Bonita Springs, FL
|
|
|
Interact with System clipboard from applet.
Hi
This may not even be possible, but I'm not sure. I am trying to make an app that will be used to view documents online. It should be possible for people to copy the text from these documents to another program if they want, but I need to be able to control what they copy and append some information to the text (a citation really)
For example, say one were viewing this post and wanted to copy something out of it. The app should allow the copy, but add a citation after it so when pasted into the other program it looks like:
Quote:
"This may not even be possible, but I'm not sure."
Interact with System clipboard from applet. http://forums.devshed.com/... p1 13 Oct 2006 |
To do that I need to
1) Be able to set the system clipboard, which I can't do from an applet due to security restrictions (works as an app)
2) Intercept ctrl+c to run my own copy function which can create and append the citation text.
Is this possible at all using java, or would I be forced into doing something with activex or something else?
I'm thinking the first point should be possible, though I may need to sign the applet or something, which I don't know how to do and the info I have been able to find online seems to all be outdated or doesn't work anyway.
|

October 14th, 2006, 09:18 PM
|
|
|
I'm no expert on Java applet security, but I suspect signing the applet may be the only way around this in pure Java.
Have you noticed that you can set and examine the clipboard contents in JavaScript?
Code:
function SetClipBoard(x) {
window.clipboardData.setData("text",x);
}
You might be able to use something like this to pass data to/from your applet?
|

October 17th, 2006, 09:51 AM
|
 |
Wiser? Not exactly.
|
|
Join Date: May 2001
Location: Bonita Springs, FL
|
|
Signing the applet seems to have worked well. Incase anyone wants to know, here's a little .bat file I made which compiles the class, packes it in the archive and signs it. Might be useful to people looking to see how to sign an applet.
Code:
@echo off
echo Cleaning environment...
del *.class
del *.jar
echo Compiling...
javac applet1.java
if not %ERRORLEVEL% == 0 (
echo Compile failed.
goto done
)
echo Packaging
jar cvf MyApplet.jar .
echo Signing...
jarsigner MyApplet.jar mykey -keypass abcdef
if %ERRORLEVEL% == 0 (
echo Running...
start http://localhost:8008/java/applet1.html
) else (
echo Signing failed
)
:done
You have to setup the key first, which you can see how to do that from this page in the sun documentation
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|