0

I'm currently working on project which focus on collaborative drawing application.

What I want to do is when I draw something on my side (Drawing on a jPanel) send that drawn content to another machine through network when I press the send button.

Drawing part is already done. Is there any way to get the content?

j0k
  • 22,600
  • 28
  • 79
  • 90

2 Answers2

2

You simply need to invoke the paint method of your Panel passing your own graphics and convert it as an image.

It has already been answered: Convert JPanel to image

Community
  • 1
  • 1
mkhelif
  • 1,551
  • 10
  • 18
0

You could draw to a backing buffer (such as BufferedImage), this would then be painted to you pane and the BufferedImage could then be passed to any one else on the network.

This may be a little heavy, it might be better to devise a solution that passes a series of commands between clients that describes actions that need to be implemented. If done right, you could end up with simply passing vector based commands that would then be scaled at each client, so that if I'm running the application on my uber 4k screen and your on your laptop, it would still render accordingly.

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366