CSC 161 Java FX Palindrome Project

(Project 2)


Your task in this project is to write a JavaFX program that recognises palindromes. Recall that a palindrome is a string that reads the same backwards as forwards. Examples of palindromes include

mom   dad   mama   radar

The empty string is considered a palindrome.

The user interface

Your user interface should look like the following sample screen shots:

In particular, the stage should have a title. You should two text fields, one for the user to enter a string to check, and another text field to display the result of the check. Each text field should have a label to the left of it to let the user know what the text field is is for. You should have a button that the user can press after entering a text field. An event handler set on this button will compute the result and display either true or false in the result text field at the bottom.

How to check a string to see if it is a palindrome

The StringBuilder class in Java is used to hold strings when you need to be able to change, or ``mutate" a string. It has a reverse method that reverses the string that is stored in the StringBuilder object. You can of course retrieve the string stored in a StringBuilder using its toString() method.

A quick way to check a string to see whether it is a palindrome is to create a StringBuilder with a copy of the string, reverse the string builder, and pull the string out of the string builder and check to see if it is equal to the original string.

Miscellaneous Hints

Text fields are discussed on page 1026 of the text book. Notice in particular that you can set the number of columns (or characters) that the text field will display. You can use a column count of 15 for the entry text field and 6 for the result text field.

Due date

This is due Wednesday July 5. Start working on it right away so if you run into problems you can ask me for help on Monday.

To submit, zip up the entire Netbeans project folder and attach to an email and email it to me, with the subject heading "Project 2 Submission." If you are not sure how to zip up the folder, ask me on Monday and I will give you a demo.


Note that this is project 2. Project 1 is Programming Challenge 15.1 on page 1038. If you have not yet done project 1, you can turn in by Wednesday July 5.