Hi all, I am having a hard time coming up with the best way to display output in a thread. Right now my program works but the output (a clock) is displayed to the comand window. I would like to have it displayed to a new window. When I tried this, instead of the thread updating the time it created a new window, so I had windows poping up all over. I also had trouble figuring out how to pass a booleen (when the user presses a button on the window that displays the time) to stop the while loop. Here is what I have so far that works.
What I would like to know is what is the best way to percede: 1) a seperate class for the display 2) use one class and implement runnable instead of extending thread should I take the creation of the clock string out of the while loop?
thanks everyone, i did not end up using indexOf(),, although I do understand it a little more. i still have not figured out how to keep a negative number when changing to an int ,, but here is what i did to avoid the exception:
Thanks for the help Marilyn, I looked up the method indexOf() and am a little confused by what index means: "Returns the index within this string of the first occurrence of the specified character. " And when you say, "You can check for indexOf( '-' ) and deal with the negative input if you find one. " deal with it how? I need to differentiate between positive and negative so I may change my clock by that amount. should i try to look for the '+'?
I have a program that is getting input from a text file. One of the values is in the format of: + or - , a number ex. -1, +4.5, -2.75 these are coming in as strings. when i try to change them to an int, i get an exception. java.lang.NumberFormatException: +1 I need an int to change the hour on a clock: cal.add(Calendar.HOUR, getOffset()); getOffset() returns an int that has been changed from a string in setOffset(). Any ideas? Thanks!