Menu

Home

JF Digonnet

Bienvenue sur le Wiki consacré à l'application Gestion de BD

La lecture des pages Web utilise la bibliothèque JSOUP disponible à l'adresse suivante : http://jsoup.org/

Pour copier des images depuis le presse papier : http://elliotth.blogspot.fr/2005/09/copying-images-to-clipboard-with-java.html

Exemple de code :

/**
 *

 * @author tom
 */
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class Main {

    /**

     * @param args the command line arguments
     */
    public static void main(String[] args) {
        //create clipboard object
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        try {
            //Get data from clipboard and assign it to an image.
            //clipboard.getData() returns an object, so we need to cast it to a BufferdImage.
            BufferedImage image = (BufferedImage)clipboard.getData(DataFlavor.imageFlavor);

            //file that we'll save to disk.
            File file = new File("image.jpg");

            //class to write image to disk.  You specify the image to be saved, its type,
            // and then the file in which to write the image data.
            ImageIO.write(image, "jpg", file);
        }
        //getData throws this.
        catch(UnsupportedFlavorException ufe) {
            ufe.printStackTrace();
        }

        catch(IOException ioe) {
            ioe.printStackTrace();
        }
    }
}


MongoDB Logo MongoDB