Coders Packet

Captcha generator and checker using Java

By Gurleen Kaur

This project uses the Java Random class to generate a captcha string of length 6 characters. The GUI is made using Java Swing and awt packages.

The GUI consists of a label in which the captcha is displayed, a reset button that generates a different captcha, a textbox to enter the given captcha interpretation, and a submit button. 

The classes include a Choice class that generates random numbers in a range, a class named RText that returns random characters to be added to the label displaying captcha, and a Captcha class that is the main class.

The label on which the captcha is displayed uses the random class to choose random fonts and the characters that are returned from the RText class are added to the label. 

The user should enter his/her best interpretation of the captcha in the textbox. 

When the submit button is clicked, the text in the label and the captcha are compared.

If both the strings are equal the check method returns true and the text "You can continue" appears on a label under the textbox. 


If both the strings are not the same, the check method returns false and an error dialogue box with the message "Please try again later" pops up. 


When the reset button is clicked, the class is called again and a different captcha string is generated. 


Download Complete Code


No comments yet