开发者

Cannot Find Symbol for Jcaptcha Background Generator

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.FunkyBackgroundGe开发者_StackOverflow中文版nerator;
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);


    }

}


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.

  • FunkyBackgroundGenerator, it can be used for gradient too.
  • MultipleShapeBackgroundGenerator
  • FileReaderRandomBackgroundGenerator

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);
}


Here is a complete detailed example/implementation JCaptcha using three alternate backgrounds:

http://kahimyang.info/kauswagan/HowtoBlogs.xhtml?b=532

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜