It is currently Sat Jun 15, 2024 9:19 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post Post subject: Java
 
Offline
Unstoppable
Unstoppable
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership

Joined: Sun Nov 15, 2009 8:40 pm
Posts: 1038
Karma: 10
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


Tue Apr 27, 2010 11:47 pm 
 Profile E-mail  
 
 Post Post subject: Re: Java
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
Java is ugly.

_________________
Follow your heart and live the dream <3


Thu Apr 29, 2010 1:33 pm 
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Karma functions powered by Karma MOD © 2007, 2009 m157y