jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes a bit of advice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "a bit of advice" Watch "a bit of advice" New topic

a bit of advice

joew weakers
Ranch Hand

Joined: Aug 21, 2003
Posts: 48
Hey there. Not too sure if I should be posting this query here but it is so general that I wasn't sure where to post it. Basically what I want to do is to record every user interaction that a particular user has with a map representation in some sort of log file. My program renders maps to the screen and the user can switch features on and off and zoom in and out of various regions in the map. The program is set up to catch mouse events so that if the user clicks on, selects or drags on any part of the map, using the mouse, this can then be recorded. So simply is there any particular approach to recording these mouse events in logs or some other format that would best suit the requirements of my system. I am merely looking for advice on what is the best method to record user interaction wit hmy map system. Thanks a lot ... Joe
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 805
Hi, Joew -
I'm assuming that you're running this on a server.
Off the top of my head, I think the simplest solution would go something like the following:
Upon startup, your server can open a log file for the day's events, then pass that File object to a FileWriter. Your mouse event handler can write the name of the object triggering the event, and the mouse x-y coordinates, or any other info you may want to capture, to a simple text file using the FileWriter.
FileWriter has a write method that appends to an existing file:

Hope that helps.

Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
joew weakers
Ranch Hand

Joined: Aug 21, 2003
Posts: 48
Thanks Jeff. I will give that a shot
It is sorta covered in the JavaRanch Style Guide.
subject: a bit of advice
It's not a secret anymore!