How to show captcha in java swing application

I need to add captcha verification code in a java swing application. I searched for some libraries (JCaptcha and SimpleCatcha), but they are for web development.

Is there any library for using captcha on a swing? and if it’s not, is there a web page or a repository with some captcha characters to implement my own captcha?

I really appreciate your time and your help.

Thanks in advance.

+5
source share
2 answers

JCaptcha can return a BufferedImage. From there it is not so difficult to get an image using JLabel:

BufferedImage captcha = // Get the captcha
// See also com.octo.captcha.service.image.AbstractManageableImageCaptchaService.getImageChallengeForID(String)
JLabel label = new JLabel(new ImageIcon(captcha));
// ... add that label to a visible container of your Swing application

1.0 : http://jcaptcha.sourceforge.net/apidocs/1.0/com/octo/captcha/service/image/AbstractManageableImageCaptchaService.html

2.0-alpha1 : http://jcaptcha.sourceforge.net/apidocs/2.0-alpha1/com/octo/captcha/service/image/AbstractManageableImageCaptchaService.html#getImageChallengeForID(java.lang.String)

Locale.

DefaultManageableImageCaptchaService.

+4
BufferedImage captcha = // Get the captcha

// See also 
com.octo.captcha.service.image.AbstractManageableImageCaptchaService.getImageChallengeForID(String)

JLabel label = new JLabel(new ImageIcon(captcha));
// ... add that label to a visible container of your Swing application
0

All Articles