• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to Save applet page as a JPG file

 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

How to Save applet page as a JPG file ?

Thanking You.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The java.awt.Robot.createScreenCapture method can take screenshots, but the applet would need to be signed to be allowed to do this.
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sir,

Thanks for your mail. Actually I am doing Web application.

My application have installed in the server machine.

I have accessed this application in the another(client) system.

When I click save screen button, i can create the .jpg screen. but it looks

server system .jpg screen but not in my client screen.

1) How can capture client system image (.jpg) screen
2) How can store that .jpg file in the client system.

Thanking You.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused. Isn't the "Save" button -as well as the code doing the screenshot- part of the applet? Where does a web application enter the picture?
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I have one Applet Graph. under the applet I have html save button. When I click the html save button, the entire screen of the Graph page should be stored as a image (.jpg) file.

That's all. It's working in server machine(application installed machine).

But when i access graph page in the other machine (client), and click the html save button, but it shows the server system desktop screen shot. Hope you understand. Because application is running in the server system.

Please let me know if you a doubt.

if you have any other way, please tell me

Thanking You.
Regards,
Edi
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to take a screenshot of the client system, then obviously the code to do so must be running on the client, not the server. So I'd say you need to move that code into the applet.
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try{
BufferedImage screencapture = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );
// Save as JPEG
File file = new File("c:/report_image_format.jpg");
ImageIO.write(screencapture, "jpg", file);

}catch(Exception e)
{
LOG.info("Screen Capture Error : "+e);
}

This is a applet code. right?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's Java code.

It can run in an applet if you put it there. But you seem to have put it into the server code (where GUI code really has no place, because nobody will see it).
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sir,

My Graph is a applet. If I create one applet button. And in it's clicking action, can I put that codes?

if i put these codes in applet, Client machine can get their own system graph jpg file?

Thanking You.
Regards
Edi
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. See my first post in this thread.
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your mail.

where can i find your first thread regarding this?

And please tell me any other way to get screen shots (.jpg) file in client machine using other than applet?

thanks.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

where can i find your first thread regarding this?


Not first thread - my first post in this thread. You can find it closer to the top of the screen
[ April 25, 2008: Message edited by: Ulf Dittmer ]
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the applet button click, i have tried, but i am not able save the jpg file in my local system. how?

my code looks like

public void actionPerformed(ActionEvent event) {
label.setText(waitingMessage);
if(event.getSource() == button)
{
System.out.println("cancel button clicked...");
try{
// capture the whole screen
BufferedImage screencapture = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );

// Save as JPEG
File file = new File("c:/screencapture.jpg");
ImageIO.write(screencapture, "jpg", file);
System.out.println("screen capture finished : ");
}catch(Exception e)
{
System.out.println("screen capture error : ");
}


}
}
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does "not able" mean? What happens when you run the code you posted? If there are exceptions, tell us which ones, and in which lines they occur. Right now, the code throws away all information about exceptions that would help debug the issue - add an "e.printStackTrace()" to the exception handler.
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,

that jpg file not created in my local system.

i have tried "e.printStackTrace()" also. But i am not getting any error.

when i run the applet code in command prompt, the jpg file created in my local system.

but when i put the applet code in the webpage, the jpg file have not created.

Please give me your suggestion.

thanks
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you're actually seeing "screen capture finished" being displayed, but no file is created?
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. You are Correct. File have not created.

Please send me your suggestion.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you seeing "screen capture finished" being displayed?

If not, then you must see "screen capture error". In that case, print out the exception information, so that you know what the problem is.
[ May 14, 2008: Message edited by: Ulf Dittmer ]
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
try{
// capture the whole screen
BufferedImage screencapture = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );

// Save as JPEG
File file = new File("c:/screencapture.jpg");
ImageIO.write(screencapture, "jpg", file);
System.out.println("screen capture finished : ");
}catch(Exception e)
{
System.out.println("screen capture error : ");
}
}

--> This program will capture final out come of the applet sceen....

Thanks,
Jaffer
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeffer, how is the code you posted different from the one Edward posted before?
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any solutions or suggestions please?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

any solutions or suggestions please?


In my post on 5/14 I asked a couple of questions. Without knowing the answers to those I don't know what else to tell you.
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i got only screen capture finished only. i did not get any error messages using - printstack trace.

please advise.

any reply...
[ August 03, 2008: Message edited by: Edward Durai ]
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please advise regarding the above problem

thanks
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello Ulf Dittmer,

are you there?

any help....
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My guess would be that the file is being created, just not in the location where you expect it to be. Is "c:/screencapture.jpg" a valid filename in the root directory? Meaning, if you use it with this code in an application (not an applet), does a file get created in the root of the C: drive? Assuming, of course, that you run the application in a directory other than the C: root directory.
[ August 14, 2008: Message edited by: Ulf Dittmer ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic