jo tay

Greenhorn
+ Follow
since Jul 28, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jo tay

When I tried OpenOffice I wasted too much time making my documents look decent in word format.
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 Rene !
great link Dirk!
I must say I have learned a good bit more Java today than I have in awhile!
19 years ago
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:
19 years ago
so would this programming logic make sence:

i'm still not positive on how to use indexOf, but i will go do some experimenting.
19 years ago
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 '+'?
19 years ago
Thanks for the help Rene,
I tried this several different ways and was not able to get it to work.

C:\My Documents\javaps\ajava2\week4\ex\exper\ClockThread.java:49: incompatible types
found : java.lang.Integer
required: int
offset = new Integer(s);

C:\My Documents\javaps\ajava2\week4\ex\exper\ClockThread.java:50: cannot resolve symbol
symbol : method parseInt (java.lang.Integer)
location: class java.lang.Integer
offset = Integer.parseInt(i);
19 years ago
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!
19 years ago