Welcome to JavaRanch, Ishrat Hasan!
While it might be mometarily entertaining to guess at the details and solution of your exact problem (mind you I'm using entertaining in the sense of "a nice distraction while I'm not writing that term paper in the middle of the night"), JavaRanchers could probably do a better (and more efficient) job of helping you out if you were to post any relavant example code that you've been working on. The alternative would seem to be some guessing about your exact implementation detail problem, and you saying "nope" repeatedly. So, let's see the code please.
Note: When posting code, please be sure to surround the code with the [code] and [/code]
UBB Tags. This will help to preserve the formatting of the code, thus making it easier to read and understand.