Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse Listener

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hello,

I am making one of those applets that give you the X and Y coordinate points when I click on a spot.
The problem Im having is getting it to display the coordinates. I mean I have to minimize the applet and maximize it everytime I click on a spot to see the coordinates refresh. Anyone know what the heck I did wrong?

 
I would need to see your code to see how you are handling the display of the coordinates to provide detailed help.

However you need to make sure after you update the component you with the coordinates that you make it repaint. If you are using a any JComponent you woulld just call it's updateUI() method. If you are using something else you would have to look at it's docs to get its method of repainting. Usually it would be repaint() or update().

If this does not help, post your code, and I will see if I can be of more help.

Rodney
 
Generally, if you find yourself having to call repaint() or update() for a GUI component its because you aren't using the component properly. Make sure that you use the component's model (where there is one) to change data values. The component will be listening to its model and change its display. Alternatively for JLabel and JTextField calling setText(..) should do the trick, if not there might be something too local about how you created and added the display object. Jeremy Nicholson, Director of a UK-based Java and Data Warehousing consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top