954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Word counter program in java

Hi everybody,

I am planning to build a java programe named word counter. It shall have file view and help menu. A text field where user can type or paste text. A button which starts counting number of words in the text. and a text field where the total number of words will appear.I just wrote small program using swing joptionpane that counts words but it doesn't look like much a stand alone programe. So what i need to write a program.Is there anyone can help me with matter. I will be thankful to him so much. I also have drawing to illustrate my program so I am attaching that one with this post.

regards
dreams.

Attachments Word_Counter.jpg 17.27KB
dreamslct
Newbie Poster
7 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

Well, lets see your code, but, to tell you the truth it is nothing but a small, simple GUI, a FileReader and String's split method.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

Hi there, Pleasure seeing your reply to my post. Also if you could help me with code I will be so thankful to you

dreams.

If by that you mean "can I write it for you", no I can't. Post your attempt here and I will help you correct. I will suggest a borderlayout with the textarea in the center, the top part as a panel with flow layout north and ananlog for the bottom and south.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

Hi, i saw your reply to my problem.

Here is a chunk that i wrote in java with joptionpane class.

import javax.swing.joptionpane;

                public class WordCounter {

           public static void main (String [] args) {

          string str;
          str = joptionpane.shwoInputDialog("Enter text here ! ");
          string[] mystring = str.split("\\s+");
  JoptionPane.showmessagedialog(null, "Words " + mystirng.length);
       System.exit(0);
}

}

======================================================================

but i don't know how to do this with jframe , could you help me with this.

dreamslct
Newbie Poster
7 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

Okay? So the "theory" is there (maybe). But I still need to see at least the attempt at a GUI (which JOptionPane in that manner, IMHO, is not). There is a huge difference. You will need to manage a couple of layouts and use an actionlistener and add components to the containers none of which are necessary for JOptionPane and I am not going to do that for you, as I alredy said). I can guarantee you've already covered this stuff in your class.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: