Gooday Note Scrap Source Android login
 
작성일 : 11-04-26 17:28
Java 화면 캡쳐
 글쓴이 : 기리 (124.♡.25.162)
조회 : 3,172  
   http://www.tvnuri.com/module/study/%EC%9C%88%EB%8F%84%EC%9A%B0%20%ED%9… [849]
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;

public class ScreenCapture extends Frame{

    Robot r = null;
    Window f;
    
    Button b;
    Dimension dimScreen;
    BufferedImage buffer;
    BufferedImage capture;
    
    public ScreenCapture(){
        try{
            r = new Robot();
        }catch(Exception e){
            System.err.println(e);
        }

        b = new Button("Capture");
        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                captureAll();
            }
        });

        add(b,BorderLayout.SOUTH);
    }

    public void captureAll(){
        this.setVisible(false);
        
        //전체 화면 사이즈 구하기
        dimScreen = Toolkit.getDefaultToolkit().getScreenSize();
        buffer = r.createScreenCapture(new Rectangle(0,0,dimScreen.width,dimScreen.height));
        
        CaptureImage c = new CaptureImage(buffer);

        //윈도우가 생성되지 않았을 경우 생성한다.
        if ( f ==