eww
Code:
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
@SuppressWarnings("serial")
class capture extends JPanel
{
public static void main() throws Exception, IOException
{
takePicture();
}
@SuppressWarnings("deprecation")
public static void setupScreen()
{
JFrame frame = new JFrame("Fourth Button");
frame.setTitle("Camera");
frame.setSize(150,100);
Container contentPane = frame.getContentPane();
contentPane.add( new capture() );
frame.show();
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.setColor(Color.black);
g.drawString("Taking Pictures", 30,30);
g.drawString("Press f5", 49,40);
}
public static void takePicture() throws AWTException, IOException
{
BufferedImage screencapture = new Robot().createScreenCapture(
new Rectangle( Toolkit.getDefaultToolkit().getScreenSize() ) );
//loop
int i = 0;
boolean exists = false;
while (i <= 1000) //Less than 1000 images...
{
exists = (new File(i + ".jpg")).exists(); // update the bool
if (exists)
{
System.out.println(i + ".jpg already exists");
}
else
{
// file doesn't exist
File file = new File(i + ".jpg");
ImageIO.write(screencapture, "jpg", file);
break;
}
++i; // add 1 to the number
}
}
}
So it was working all fine and dandy (creating a screenshot, and saving it incrementally) but then I added a JFrame and tried implementing a keyboard listener (so that it could be activated via keyboard buttons)...
What is wrong with this??
Code:
java.lang.NoSuchMethodError: main
Exception in thread "main"
(That's all it gives)..
_________________
Skillers wrote:
Oh gawd no! Not the crazy frog! Arghhhhhh! $&^%&*^%*$^ %$(%^((% %$(O*%(#*%^ %)*#$&%)*@#% %_(#&%*%) frog