logo CodeStepByStep logo


Write a complete program named WordProcessor with a graphical user interface that creates a simple word processor. Your program should consist of a JTextArea on the left, and a set of interactors on the right. Implement the following set of interactors:

  • Update Stats: Create an "Update Stats" button, along with JLabels for the number of characters, words, and lines in the document (excluding whitespace). Every time the user clicks the button, you should recalculate the stats over the current text of the JTextArea.
  • Make List: Create a "Make List" button that converts every line of text to a list by adding either a * or a - to the beginning of every non-whitespace line, followed by a space. You should allow the user to toggle between lists of * and - using a set of radio buttons. Your program should look like the figure below.
  • Change Font: Create a text field that allows the user to type a different font name to be used in the main text area region.
  • Change color: Create a button that, when clicked, pops up a color chooser to change the color of the text in the main text area.
  • Upper/Lowercase: Create buttons that will change the casing of the text in the text area.
  • Sort Lines: Create a button that, when clicked, arranges the lines in the main text area so that they are sorted in ABC order. (Hint: Use the Arrays.sort method to help you.)

This exercise does not have any test cases associated with it. You can look at this exercise and try to write your own solution on your computer in a text editor, but you cannot submit it here for testing. We're sorry for the inconvenience.

Need help?

If you do not understand how to solve an exercise or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect tests, etc.), please

Is there a problem? Contact a site administrator.

©, all rights reserved.