![]() |
Java Swing Word Counter
I am a student, and need a little direction. My instructior wants us to use the Swing Method to create a Word Counter in java.
I have it all written out, and it compiles. But the program will not go past the CMD.exe screen. It just hangs there. Any help would be appreciated. Thanks. Here is the Code. PHP Code:
|
Quote:
In this case, variable str is never changed from the original value. Consider using a (it has beena while since I've used a buffered reader, but this looks right): while (null != (str = reader.readLine())) instead. |
Thanks, but now I am more confused. This while statement does it have to be in the main method, or another place? I guess what I am asking is where int he code do I put it?
Sorry for being so ignorant, but I am still trying to wrap my head around Java. |
It replaces your current while loop which is infinite in its run.
|
I tried it, and now I get a Compiler error. reader.readLine symbol not fount. Is this suppose to be dataIn.readLine.
|
Yeah it is, my bad.
|
Thank you for helping. But after i inserted the Code you gave me, and compiled it. I am still getting the CMD.exe window hang. The program just sits there, and does nothing.
PHP Code:
|
Loop with this instead, this works fine:
while (null != (str = dataIn.readLine()) && !str.isEmpty()). The code itself doesn't really do anything, but you need to interact with the cli interface before it will launch the gui. |
Did that, and now I have a Compiling Error. I know you are going out of your way, and I would like to thank you for helping me this far.
Here is the Error. Quote:
|
You must be on java 5.
Use str.length > 0 instead of !str.isEmpty. |
Thank you, so much.
I replaced it, and the code compiled. But, I am still getting the Hanging at the CMD.exe problem. No error, just hangs there. I also added import java.lang.*. But still get the hang. I am overlooking something easy I know it. This is due tomorrow night at midnight. I am really starting to stress out here. |
Quote:
|
| All times are GMT +1. The time now is 02:02 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.