I have a screenshot program I made, and for some reason it "draws" to the screen. It really does that thing that Windows likes to do(and I hate it) when it freezes up and you can see random crap like the edge of your window that isn't there anymore.
The only problem is, it does this, and takes a screenshot when I look away from the program.
Here is my code:
BTW, sorry for the name of the topic, I meant "Screenshot wont draw to form" :Limport java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; import javax.swing.JFrame; public class GuiStart extends JFrame { private static final long serialVersionUID = -621866894461974337L; public static BufferedImage remoteDisplayImage; public GuiStart() { Thread updateThread = new Thread(new UpdateScreen()); updateThread.start(); } @Override public void paint(Graphics g) { Image img = remoteDisplayImage; g.drawImage(img, 0, 0, this); } } class UpdateScreen implements Runnable { public void run() { while (true) { try { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screenSize = toolkit.getScreenSize(); Rectangle rectangle = new Rectangle(0, 0, (int)screenSize.getWidth(), (int)screenSize.getHeight()); Robot robot = new Robot(); BufferedImage shot = robot.createScreenCapture(rectangle); GuiStart.remoteDisplayImage = shot; } catch(Exception ex) { ex.printStackTrace(); } } } }