• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Saving a picture of an applet

 
Tokai Moshai
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65128
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the Applets forum.
 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic