tags:

views:

115

answers:

1

Hi, I am creating a Jcaptcha engine so that I will be able to set the background of my jcaptcha to blue. I tried following the example on 5 Mins Integration Tutorial, under the comments they have a small example of how to configure the jcaptcha.

However my netbeans reflected that the SingleColorGenerator and FunkyBackgroundGenerator cannot find symbol. Can anyone point out what am I suppose to do to resolve this issue? Thank you.

[EDITED]

The Jcaptcha Engine Configuration code as per below:

package com.test.controller;

import java.awt.Color;

import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator;
import com.octo.captcha.component.image.backgroundgenerator.FunkyBackgroundGenerator;
import com.octo.captcha.engine.image.ListImageCaptchaEngine;

public class myCaptchaEngine extends ListImageCaptchaEngine {

    protected void buildInitialFactories() {
        ColorGenerator cg = new SingleColorGenerator(Color.blue);
        BackgroundGenerator background = new FunkyBackgroundGenerator(250, 100, cg);


    }

}
A: 

As its name suggests, its a Unicolor, which is white according to the specs. You can't pass Color as an argument to its constructor. The constructor just take 2 arguments, length and height, respectively. The color will be white and that makes it useless in your case.

Now try any of these to achieve your desired thing. The first one is simple, where you can define multiple colors.

Thanks for the Javadocs link. :)

[Edited]

A spoon feed below, based on your given code.

protected void buildInitialFactories() {
    ColorGenerator cg = new SingleColorGenerator(Color.blue);
    BackgroundGenerator background = new FunkyBackgroundGenerator(250, 100, cg);
}
Adeel Ansari
I think the Javadocs is over here: http://jcaptcha.sourceforge.net/apidocs/1.0/
jl
@jl: Aha, good. So now where is the problem? I hope you already managed to get the thing. Right?
Adeel Ansari
@Vinegar: nope, the error still exists. Even if I remove the color from the list, or input as white, the `new UniColorBackgroundGenerator` is still producing the `cannot find symbol` error.
jl
@j: Checkout the docs mate, the constructor doesn't accept any color argument. It just use white as default. I already told you that this class is of no use here, in this case. Instead, use FunkyBackgroundGenerator, check my addendum to the post.
Adeel Ansari
@Vinegar: Maybe i should rephrase my qn...I have edited the script as per above, but i still have the `cannot find symbol` issue. May I know did i miss any libraries required but not included? I still cannot figure what libraries I might be missing.
jl