Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java drawing coordinates on multiple screens

 
Amit Shef
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm making a game like "Draw My Thing".

Now, in this game of course, a server is required, for which every person can see what the other player is drawing.

I managed to paint from one screen to another, but the problem is that the coordinates of the drawings are not the same if the dimension (WIDTH AND HEIGHT) of the screen is different.

Here's some code to begin with:

PAINT COMPONENT



Server

NOTE:

oldX, oldY, currentX, currentY are values sent from the client

 
Fred Kleinschmidt
Bartender
Posts: 415
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should never call repaint() from the paintComponent() method or from any method called by the paintComponent() method. That will cause the paintComponent() method to be called again - an infinite loop.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic