The Artima Developer Community
Sponsored Link

Java Answers Forum
I want to export all the instructions contained in the main in a procedure

2 replies on 1 page. Most recent reply: Apr 12, 2006 6:59 AM by gianluca Del Vecchio

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
gianluca Del Vecchio

Posts: 7
Nickname: vedder1981
Registered: Apr, 2006

I want to export all the instructions contained in the main in a procedure Posted: Apr 11, 2006 3:33 AM
Reply to this message Reply
Advertisement
i have this program that allow to capture a screenshot:

I want to export all the instructions contained in the main in a procedure out of the main, in such way not to be had instructions in the main.

Someone can help me? THANKs!

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.ImageIO;

class ScreenCapture {
public static void main(String args[]) throws
AWTException, IOException {
// capture the whole screen
BufferedImage screencapture = new Robot().createScreenCapture(
new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );

// Save as JPEG
File file = new File("screencapture.jpg");
ImageIO.write(screencapture, "jpg", file);

}
}

i have to create a single procedure


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: I want to export all the instructions contained in the main in a proced Posted: Apr 11, 2006 4:23 AM
Reply to this message Reply
Please format your code, google: "Java Tutorial Methods"

Sounds like a newbie request, unless I have misunderstood it.
In the mean time here is what you seemed to be looking for:
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.ImageIO;
 
class ScreenCapture {
   public static void main(String args[]) {
      ScreenCapture capt = new ScreenCapture();
      capt.captureScreen();
 
   }
 
   public void captureScreen()throws AWTException, IOException{
      BufferedImage screencapture = new Robot().createScreenCapture(
      new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );
 
      // Save as JPEG
      File file = new File("screencapture.jpg");
      ImageIO.write(screencapture, "jpg", file);
   }
}

gianluca Del Vecchio

Posts: 7
Nickname: vedder1981
Registered: Apr, 2006

Re: I want to export all the instructions contained in the main in a proced Posted: Apr 12, 2006 6:59 AM
Reply to this message Reply
THANKs!

Flat View: This topic has 2 replies on 1 page
Topic: Assistance with two Iteam Personal project. Previous Topic   Next Topic Topic: opaque

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use