'Cast server screen to client using java

I want code for server and client.

Whatever is displayed in server screen should be displaying the same in client screen in jframe using java networking.

I have done but the problem is multiple frame are being created inside one jframe

Thanks in advance



Solution 1:[1]

  1. If you are not painting the server screen inside the application, you can take a screenshot, and send that file to the client. Its quite slow tbh.
  2. If you are painting it, then you should send these 'paint commands' to the client. E.g. if you send "rect 0 100 200 150" the client would paint a rectangle to the screen at 0,100 with width=200 and height=150. To make that, you have to override the paintCompontent() method of the JFrame. And dont forget to start the painting by filling the JFrame with backgrond color to avoid seeing the remains of previous frames.

Solution 2:[2]

Use the Robot class to take screenshots, adjust the windows size by Display or typing manually and send using DatagramPackets

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tibetiroka
Solution 2 Allan