Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Martin Mathis

Ranch Hand
+ Follow
since Dec 20, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Martin Mathis

That call to interrupted() sets the interrupt flag to true, so isInterrupted() returns true and breaks out of the loop.
System.getCurrentTimeMillis() returns "the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC."

All you need to so is get the current time using the above method whenever a note is pressed. Store them however you want, either group the note and timestamp together in an object, or store them in seperate arrays with identical indexes.

If you want to go back and compare the differences in time, use simple subtraction.
Pick your version...

Follow that link for the javadocs. In this case, temp[] is just the place the results of the split operation (an array of strings) are stored. In this case, split breaks it into pieces by spaces, and each piece is an element in the array.
15 years ago
To me, it looks like SwingWorker isn't much more than an abstract class that will make it easier to implement the Virtual proxy pattern.
You could always put everything in a batch or wsh file and have task scheduler run that.
15 years ago
I guess I was thinking more along the lines of something like this...

Don't know if there's something wrong there or not, just whipped it up really quick.
15 years ago
I think it'd be a lot easier if you did it while reading the lines, instead of doing all the reading up front.

If you keep reading (and storing them) until you get to one that has an end timestamp, you know that every line in your array/list/etc... needs to be linked. So do the linking, removing them, and go back to reading some more.
15 years ago
I'm not really sure what you're asking with the whole inverted index thing. But I can tell you how I'd probably tackle the overall problem.

For each file, I'd read it and create a Map with the term as the key and their frequency as the value.

If you have a Map for each file it should be pretty easy to figure out the document frequency (by using containsKey() on each Map). The term frequency would just be the sum of the value retrieved from each Map for the given key.
15 years ago
How about making a method that calculates (and RETURNS) the gross amount, given inputs of hourly rate and hours worked.

Create another method that calculates (and RETURNS) the net amount, given input of the gross amount.

then your calls to them would just look like the following

If it absolutely needs to be one method, consider creating a object or using some sort of structure to return all of the values you want to return.
15 years ago
Have you tried using a debugger or output statements so that you can actually see how things are running? I'd assume that the if statement never evaluates to true, so you're left with the initial null values.
15 years ago

Originally posted by Victoria Preston:
so Tony what would you do.....

I have had no luck at all i'm stressed i'm going to cry

All you need to do is...

1. Create a new array (larger)
2. Copy the contents of the old array into the new one (System.arraycopy(..), or a loop)
3. Make the reference to the original array point to the new one

All you have to do is convert those 3 lines to code and you're finished.
15 years ago
Yeah, all you need to do is open a file, call toString(), write its contents to the file, and close the file.
15 years ago

Originally posted by Karen Baog:
I don't want to use sleep().

Just curious, but what's wrong with using sleep()?
My guess is that myPaintCanvas (in MyPaintButton) is null. Do you have the code for that?
[ January 09, 2006: Message edited by: Martin Mathis ]
16 years ago

Originally posted by Layne Lund:

Isn't that what I said? I guess great minds think alike.

Haha. I don't know how I missed your reply Maybe its a Monday morning thing, hehe.
16 years ago