我需要在Java Swing应用程序中添加验证码验证器。我已经搜索了一些库(JCaptcha和SimpleCatcha),但它们是为Web开发准备的。
有没有适用于Swing的验证码库?如果没有,是否有一个网页或仓库有一些验证码字符可以实现自己的验证码?
非常感谢您的时间和帮助。
提前致谢。
有没有适用于Swing的验证码库?如果没有,是否有一个网页或仓库有一些验证码字符可以实现自己的验证码?
非常感谢您的时间和帮助。
提前致谢。
JCaptcha可以返回一个BufferedImage图片。然后使用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
Locale
参数。DefaultManageableImageCaptchaService
。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