I am building a whiteboard, which would have a server(teacher) and clients(students). Teacher would draw something on his side, which will be shown exactly same to the students.
Any help would be appreciated.
JComponent
unless you need to add other components, then use a JPanel
.if I draw a line on teacher's side, the same should happen to the child's screen, live, so there is a feeling of realtime drawing..
Then you definitely want to go the least bandwidth intensive route possible. That will be the bottleneck.
..have a JFrame, onto which i have 2 JPanels, 1 for drawing, 1 for buttons.
In that case, make the drawing component a JComponent
& stay with a JPanel
(or a JToolBar
) for the controls.
..what would be that "least bandwidth intensive route possible"?
In order of bandwidth and ignoring corner cases, they would decrease in approximately this order:
In case there is any confusion, I recommend option 3.2.
Use Robot.createScreenCapture() and broadcast the entire teacher's screen.
to capture:
sendBuffer[index++] = robot.createScreenCapture(new Rectangle(0,0,1360,768));
to display:
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(receiveBuffer[index], 0, 0, jFrame.getWidth(), jFrame.getHeight(), null);
receiveBuffer[index++]=null;
}
You'll have to do rescaling in the receiver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With