How to take snapshot of screen in Java using NetBeansIDE
How to take snapshot of screen in Java using NetBeansIDE.
1. Open NetBeansIDE.
2. Make a JFrame Form and design it.
3. RC on a button and Goto Events~action~actionPerformed
4. Write following code in it.
Note: createScreenCapture(Rectangle rect) method is used to capture screen. It is the method of Robot class.
try{
BufferedImage image=new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(image,"jpeg",new File(your path));
ImageIcon icon=new ImageIcon(image);
jLabel1.setIcon(icon);
}catch(Exception e)
{
e.printStackTrace();
}
5. Run your Project.
6. Finish.
Thank You
:)
Facebook Page
Comments
Post a Comment