Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Java Applet and Robot

Started by vlovich Oct 7, 2002 at 5:10 PM 0 replies 1k views
Original Post
vlovich
vlovich
Can someone give me a tmeplate for a java class that creates an applet and uses the robot class? Something like this:
        
import java.awt.Robot;
import java.awt.Applet;

public class MyClass extends Applet 
{
          public void init() {
          }
          
          public void paint (Graphics g) {
          // Uses Robot class here and gets pixel color for lets 

          // say pixel (0,0)

          // For some reason the following code returns an error

          // of something like "unreported exception 

          // java.awt.AWTException;  must be caught or declared 

          // to be thrown"

              Robot screen = new Robot();
              screen.getPixelColor(0,0);
          }
}
    
or if you could tell me how to run an applet from main something like:
  
import java.awt.*;
import java.awt.swing.*;
import java.awt.event.*

public class MyClass
{
          public static void main (String args[]){
          }
                 JApplet app = new JApplet ();
                 // I then set the size and position and set 

                 // visible to true.  Applet doesn't show up.

          }
}
  
[edited by - vlovich on October 7, 2002 6:54:15 PM] [edited by - vlovich on October 7, 2002 6:58:24 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.