Hmm, I'm not sure this is possible with just Java. I could be wrong, but I'll be surprised if what you're talking about is easy to implement.