I think you're clicking outside the bounds of the image.
int temp=buff.getRGB(x,y);
Will throw
ArrayIndexOutOfBoundsException
if not inside the bounds of the image.
Guard for that scenario by adding something like;
try
{
int x=me.getX();
int y=me.getY();
if (x < buff.getWidth() && y < buff.getHeight()) {
int rgb=buff.getRGB(x,y);
Color c=new Color(rgb);
System.out.println(c.getRed()+" "+c.getGreen()+" "+c.getBlue());
floodFill(x,y,c);
}
}
catch(Exception e)
{
System.out.println(e);
}
Also, I think you'll be off by the height of the windows title bar, that is to say clicking at the top of the window will not yield a y-coordinate of 0, but the height of the title bar of the window.
Hope this helps,
Fredrik
ps. Your algorithm will probably stack-overflow on all but really small images.