A lightweight Java Swing desktop application that counts the number of words, characters in a given text input.
- Real-time word, character, and space counting
- Counts all words including duplicates, based on space-separated tokens
- Simple and clean user interface built with Java Swing
- Clear button to reset input and output fields
- Exit button to close the application
- Words are detected by splitting the input text using spaces.
- Every word is counted — even if it appears multiple times.
- Characters are also calculated, which includes special characters as well(eg: " ! ?).
Example:
"hello world hello"
counts as 3 words, including the duplicate"hello"
.
Input Text:
The only way to do great work is tolove what you do
Explanation:
- The tool splits the input based on spaces.
"tolove"
is counted as one word (no space between "to" and "love")."do"
appears twice and is counted both times.
🔢 Output:
- Words: 12
Input Text:
" The only way to do great work is tolove what you do !! "
Explanation:
- The tool splits the input strictly based on spaces.
- Words like
"
,is
,tolove
,do
, and!!
are treated as individual words. "do"
and"
appears twice and is counted twice.- Punctuation is not removed or filtered—it's included as part of the word if not space-separated.
🔢 Output:
- Words: 15
-
Clone the repository:
git clone https://github.com/hema-priya-vadivel/Word-Count-Tool.git
-
Open the project in your preferred Java IDE (IntelliJ, Eclipse, etc.).
-
Compile and run WordCountTool.java.
-
Enter a sentence/paragraph in the "Enter the words" textarea and click on "Count Words" button to view the total count of words
-
Use the Clear button to reset fields or Exit to close the app.