File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes menu cut & paste in applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "menu cut & paste in applet" Watch "menu cut & paste in applet" New topic

menu cut & paste in applet

Martha Cofran

Joined: Jan 31, 2001
Posts: 11
I have a requirement to enable cut & paste from the menu in an applet. I have code that works in an applet viewer but not through the web server, although, cut & paste work on the web server when invoked with key combination (Ctl-C, Ctl-V, Ctl-X). I'm using the JTextComponent cut, copy, and paste methods in both cases, It think.
I assume the security manager is looking at where the event originated to determine access to the system clipboard, i.e. the control key combination is originating from swing (trusted code) and the menu event is originating from my code (untrusted code).
Is there a way to do this without modifying browser permissions? If not, I can go to a code base level permission scheme, but I'd rather not muck the browser permission if I don't have to.
Thanks for any help/advice you can give.
Angela Lamb
Ranch Hand

Joined: Feb 22, 2001
Posts: 156
Once again, if something works in appletviewer but not in the browser, the first thing to check is whether you are using a class/method that is not available in version 1.1(which most browsers use). JTextComponent is a Swing class, from Java 2, and is not supported in the browsers. If you look at the error message in the Java console in your browser, you should see a ClassNotFoundException that will alert you to the problem.
Martha Cofran

Joined: Jan 31, 2001
Posts: 11
Well, I don't think so. JTextComponents are working fine in my browser with the exception of cut, copy, and paste through a menu. Cut, copy, and paste are working in my browser if I trigger the events from the keyboard. The exception I'm getting is a Permission error not a class not found error.
I agree. Here's the link:
subject: menu cut & paste in applet
It's not a secret anymore!