Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: might not have been instilized

  1. #1
    Join Date
    Jan 2012
    Thanked 0 Times in 0 Posts

    Default might not have been instilized

    this is my code i have a few problems but this is the biggie:

    	    Robot robot = new Robot();
    		Color color0 = new Color(39, 36, 11);
    		Rectangle a = new Rectangle(0, 0, 1365, 770);
    		Rectangle b = b;
        BufferedImage image = robot.createScreenCapture(a);
        search: for(int x = 0; x < a.getWidth(); x++)
                for(int y = 0; y < a.getHeight(); y++)
                    if(image.getRGB(x, y) == color0.getRGB())
    				b = new Rectangle(x, y, 435, 430);
    				break search;

    i am getting error:

    java:99: variable b might not have been initialized
    Rectangle b = b;

    what i want this snippet of code to do is take a shot of the screen with Rectangle a, search the shot for a pixel, use that pixels x, y point along with the supplied width and height to set a new rectangle, Rectangle b which i use later in my code. how do i fix this error and still give the code the functionality i describe above?
    thanks guys

  2. #2
    Forum VIP
    Join Date
    Oct 2010
    My Mood
    Thanked 54 Times in 47 Posts
    Blog Entries

    Default Re: might not have been instilized

    You have multiple syntax errors, however this will solve the problem you explicitly expressed.

    Initalizing Variables by TJStretch

  3. The Following User Says Thank You to Tjstretch For This Useful Post:

    Lurie1 (February 17th, 2012)