Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset
Comments Off

Java: Capturer l’écran

 int,string,char,static, url, socket, url, socket, java
Download

/**
 * @(#)CapturerEcran.java
 *
 *
 * @author 
 *sakoba(java.mesexemples.com) @version 1.00 2013/6/10
 */
    import java.awt.Rectangle;
    import java.awt.Robot;
    import java.awt.Toolkit;
    import java.awt.image.BufferedImage;
    import java.awt.event.*;
    import java.awt.Desktop;
    import java.io.File;
    import javax.imageio.ImageIO;
    import javax.swing.*;
 
public class CapturerEcran extends JFrame
 {
 
    public CapturerEcran() 
    {
    	JPanel mainPanel=new JPanel();
    	JButton btn=new JButton("Capturer l'écran");
    	btn.addActionListener(new ActionListener()
    	{
    		public void actionPerformed(ActionEvent evt)
    		{
    			try
    			{
 
			    Robot robot = new Robot();
			    BufferedImage screenShot = robot.createScreenCapture(
			    	new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
			    ImageIO.write(screenShot, "JPG", new File("screenShot.jpg"));   
			    if (!Desktop.isDesktopSupported()) 
			    	return;
			    Desktop dsk=Desktop.getDesktop()			;
			    dsk.open(new File("screenShot.jpg"));
			    }catch(Exception err)	
			    {
			    	JOptionPane.showMessageDialog(null, err);
			    }
    		}
    	});
    	mainPanel.add(btn);
    	add(mainPanel);
    	setTitle("Imprimer l'écran");
    	setSize(250,250);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
 
 
    }
        public static void main(String[] args) throws Exception
    {
        new CapturerEcran();
    }
 
 
}

Cet article Java: Capturer l’écran est apparu en premier sur .

----------------------------------------------------------------------------
Sex Cams Movable Theme