Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

create a text analysis

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to create a Java text analysis application. This application contains a TextArea where user loads a text file into it as this application should contain a load button and process button. When the user clicks on the load button, the application should be able to load a text file and display the content in the TextArea. This can be done by using FileChooser component. When the user click on the process button, the application should count the number of lines in the TextArea, the number of words in the TextArea, and the number of characters in the TextArea. This information should be displayed on the three labels in the application. Please help me!!
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

What do you have so far, and where are you stuck making progress?
 
Melissa Lyn
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So far I have like this:



haven't really completed much stuff since I don't really know how to continue from here. And I'm not sure whether my codes here are correct too.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your program has to do 3 things
1) input some data
2) process that data
3) display the processed results

don't worry about (1) or (3), until you can get the results correct (2)
i.e hard-code a string, then get this part done via System.out.println()'s
"When the user click on the process button, the application should count the number of lines in the TextArea,
the number of words in the TextArea, and the number of characters in the TextArea."

you could even use your above sentence as the hard-code



now, when you get that part workng OK, it is a simple matter of re-directing:
1) the input via a FileDialog
2) the output to labels

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For processing words.
 
Sheriff
Posts: 22571
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mikko Kohtamäki wrote:For processing words.


I'd go for a StringReader / BufferedReader combination and String.split instead. That way, you can replace the StringReader with a FileReader when you want to replace the test string with contents from an actual file. Splitting should be done at any whitespace, comma, dot but perhaps also other non-character data. And the thing with String.split is, you can give it a regular expression. For example:

Another advantage is that you can then easily count words - just check the length of the returned String[].
 
Melissa Lyn
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically I have to do a program something like this:
Filename: Text-Analysis.bmp
Description: Text Analysis
File size: 897 Kbytes
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic