Illegal modifier for the local class Notepad; only abstract or final is permitted

why does my code return the error: Illegal modifier for the local class Notepad; only abstract or final is permitted

this is the code:

`int x=1;
int y=1;

color ring1 = color(0,0,0);
color ring2 = color(0,0,0);
color ring3 = color(0,0,0);

import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;


public class Notepad {

    static int keyInput[] = { KeyEvent.VK_J, KeyEvent.VK_A, KeyEvent.VK_V,
            KeyEvent.VK_A, KeyEvent.VK_SPACE };
            
            public static void main(String[] args) throws Exception {

        Runtime.getRuntime().exec("notepad");

        Robot robot = new Robot();
        for (int i = 0; i < keyInput.length; i++) {
            robot.keyPress(keyInput[i]);
            robot.delay(100);}}

Robot robot;
void setup() {
  size(1500, 3000);
  try {
    robot = new Robot();
  } 
  catch (Exception e) {
    println(e.getMessage());
  }
}

void draw() {
  background(0);
  Rectangle r = new Rectangle(x, y, width, height);
  BufferedImage img1 = robot.createScreenCapture(r);
  PImage img2 = new PImage(img1);
  image(img2, 0, 0);
  x++;
  y++;
  color colorFromGet = get(x,y);

if ( colorFromGet  == ring1 ){
  print( "x=" + x + " y=" + y );
if ( colorFromGet  == ring2 ){
  print( "x=" + x + " y=" + y );;} 
if ( colorFromGet  == ring3 ){
  print( "x=" + x + " y=" + y );;} 
  
  y++;
  if(y=3000){y=0; x++;}
  print(y);
}


}}`

one of the problems is that Notepad wraps everything including setup and draw. This is perhaps not what you want. Tip: use ctrl+t (or command+t on mac) on the Processing IDE to format the code, then you see the structure better!

1 Like