The right way to build an interactive whiteboard

I create a board on which there will be a server (teacher) and clients (students). The teacher would draw something on his side, which would be shown in the same way as the students.

  • I want to know which component should I use for drawing? I am currently drawing a JPanel.
  • I want the server screen to be copied on clients, so maybe this is the right way to do this?
    • option1: I save the JPanel as an image and send it through the socket and load it onto the client’s screen, it also always saves only the background image, and not what the user drew on it. OR
    • option2: the dimensions of the server and client of JPanel are the same, so I just send the new coordinates drawn each time through the socket, with some protocol to understand whether it is rubber or pencil.

Any help would be greatly appreciated.

+5
source share
2 answers
  • Use JComponentif you do not need to add other components, then use JPanel.
  • , . , . , " " . . , , (). , // .

Update

, , , .

, , . .

.. JFrame, 2 JPanels, 1 , 1 .

a JComponent JPanel ( a JToolBar) .

.. " "?

:

  • :
    • JPEG
    • PNG.
    • JPEG
  • :
    • JPEG
    • PNG.
    • JPEG
  • , :
    • ,
    • , , , .

- , 3.2.

+6

Robot.createScreenCapture() .

:

sendBuffer[index++] = robot.createScreenCapture(new Rectangle(0,0,1360,768));

:

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.drawImage(receiveBuffer[index], 0, 0, jFrame.getWidth(), jFrame.getHeight(), null);
    receiveBuffer[index++]=null;
}

.

+4

All Articles