I too once faced the same problems...
Are you using applets? or a UI? or is it just the command line??
Because if its applets or UI it can be done, I had read a article on sun Java's website for it, but in command line, its almost impossible, although I found a trick, its not very good, found it on sun's website, dont remember just now