File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes Saving a picture of an applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Saving a picture of an applet" Watch "Saving a picture of an applet" New topic
Author

Saving a picture of an applet

Tokai Moshai
Greenhorn

Joined: May 24, 2006
Posts: 16
I have an applet that shows a picture (I need that for many reasons and can't just show the picture).

Problem is, I cannot right click on the picture and do a 'Save Picture As..'. So, I'm trying to create a button, when clicked, will pop up the 'Save As..' so that users can save the picture on their computer.

How do I do that? In short, how do I get the 'Save picture as..' functionality inside JSP/HTML code?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
You can't. HTML and JavaScript have no concept of dealing with images (or files in general) in this way. The applet could do that if you gave it permission to access the local file system (which it is not allowed to access by default). This Wiki page explains how to do that.


Ping & DNS - updated with new look and Ping home screen widget
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Moved to the Applets forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Manuel Moons
Ranch Hand

Joined: Mar 05, 2002
Posts: 229
If the applet can generate the picture the server can probably do the same.

The same parameters that are passed to the applet can be passed to a server process which returns you a "real" image. You might consider changing to such an implementation. In that case you do not have problems with applets anymore.

The other choice you have is opening up security for the applet and having it implement a popup when you right click on it which gives you the same options as another image. It is best however that you work with certificates and signing of the applet. Do not open up security for the whole VM (and thus for all applets).
Tokai Moshai
Greenhorn

Joined: May 24, 2006
Posts: 16
thinking about solving it a bit different way. can I use the 'print screen' functionality (or even better a portion of the screen) using javascript? what I'm thinking is, clicking on a button will copy a portion of the web page to the clipboard and then users can do whatever they want to do with it.

I'll look into the security thing, thanks for the idea.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Saving a picture of an applet
 
Similar Threads
save applet as image
How do I save a picture in database??
Loading resources using classloader
Image location in the server?
how to save image in java