Java Web-based chat room-screenshot implementation

Source: Internet
Author: User

Package com.silianbo;/* * To-License header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */import java.awt.borderlayout;import java.awt.color;import Java.awt.container;import java.awt.Desktop;import Java.awt.dimension;import java.awt.label;import java.awt.rectangle;import Java.awt.robot;import java.awt.Toolkit; Import Java.awt.event.actionevent;import Java.awt.image.bufferedimage;import Java.io.file;import Java.text.simpledateformat;import Java.util.date;import Javax.imageio.imageio;import Javax.swing.JButton;import Javax.swing.jdialog;import Javax.swing.jframe;import Javax.swing.jlabel;import Javax.swing.JPanel;import javax.swing.jtextarea;/** * * @author Silianbo * screenshot function */public class Capturescreen {public static void Capturescreen ( String fileName, String folder) throws Exception {Dimension screensize = Toolkit.getdefaulttoolkit (). Getscreensiz        E (); RectanglE screenrectangle = new Rectangle (screensize);        Robot Robot = new Robot ();        BufferedImage image = Robot.createscreencapture (Screenrectangle);        Save path File Screenfile = new file (fileName);        if (!screenfile.exists ()) {Screenfile.mkdir ();                 } file F = new file (screenfile, folder);        Imageio.write (Image, "PNG", f); Automatically open if (desktop.isdesktopsupported () && desktop.getdesktop (). issupported (desktop.action.        Open) {desktop.getdesktop (). open (f);        } else {}}//public static void main (string[] args) {//Randomname filename= new Randomname ();// try {//Capturescreen ("c:\\users\\silianbo\\desktop\\ computer network course design", filename+ ". png"),//} catch (Except Ion e) {////TODO auto-generated catch block//e.printstacktrace ();//}//}}

  

1 /*2 * To-change the license header, choose License Headers in Project Properties.3 * To change this template file, choose Tools | Templates4 * and open the template in the editor.5  */6  PackageCom.silianbo;7 8 ImportJava.text.SimpleDateFormat;9 Importjava.util.Date;Ten  One /** A  * -  * @authorSilianbo - * File renaming, randomly generated the * The format of the file is [email protected] -  *  -  */ -  Public classRandomname { +      Public Static voidMain (string[] args) { -Date dt=NewDate (System.currenttimemillis ()); +SimpleDateFormat SDF =NewSimpleDateFormat (); AString filename=sdf.format (DT); at System.out.println (fileName); -     } -      -}

Java-based web chat room-implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.