Hi, Yes another dreaded assignment......I have to, instead of drawing a filled box, give the user the position of the mouse click in pixels when the mouse is clicked on the screen. Any cluse as to how I could modify this program to do that? Thanks, Mary Ellen
(edited by Cindy to add formatting)
[This message has been edited by Cindy Glass (edited March 31, 2001).]
Well you already have the listener set up and it already grabs the x and y coordinates for you, so all you have to do is get rid of the thing that draws the rectangle: g.fillRect(x-5, y-5, 10, 10); and replace it with something that displays a message. If you read the API for the Graphics class you will find a drawString() method that takes in a String and the x and y coordinate to display it at. So if you put in: String s ="The mouse is at x=" + x + " and y=" + y; g.drawString(s, x , y ); it should work.
"JavaRanch, where the deer and the Certified play" - David O'Meara