convert applet to image !!!!!!!!!

i have client server program i want for every change user made it the tranfer the new image of applet to server .how can i convert applet to image?
[168 byte] By [eaajea] at [2007-11-26 13:54:33]
# 1
applet to image? are you sure ? you know that stuff is impossible...
suparenoa at 2007-7-8 1:33:09 > top of Java-index,Java Essentials,Java Programming...
# 2
Why do you want to do this?
mlka at 2007-7-8 1:33:09 > top of Java-index,Java Essentials,Java Programming...
# 3

i mention i want the server to load every changes that affect by clients

iam googling the problem and i saw the solution is to get an image for every change and send it through client socket .

actually iam not understand fully , can any one explaing how to get an image from applet then send it ?

eaajea at 2007-7-8 1:33:09 > top of Java-index,Java Essentials,Java Programming...
# 4

> i mention i want the server to load every changes

> that affect by clients

I still don't understand what you mean by this.

> iam googling the problem and i saw the solution is to

> get an image for every change and send it through

> client socket .

I'd really look at sending changes in the data model, not doing a screen dump of the image.

> actually iam not understand fully ,

Maybe if you post some example code, or at something that does what you want we can offer more constructive help.

> explaing how to get an image from applet then send it

> ?

I personally think you are going about this the wrong way. You should really think about what data you want the client and server to share.

But hey, Overview: Have the applets draw method also draw to a image. Open a socket connection, use its output stream and the image as params to ImageIO.write.

mlka at 2007-7-8 1:33:09 > top of Java-index,Java Essentials,Java Programming...
# 5

thanks mlk for your interesting

i have white board project , assume there is 3 memebers in one team and every member can draw Rect , Oval , Line and it should appear in other members .

iam finish the graphic part and i want to establish the connection between white board server and clients ,

all the client share the white board ( applet ) .

i hope the idea clear now

eaajea at 2007-7-8 1:33:09 > top of Java-index,Java Essentials,Java Programming...
# 6

I would not send an Image of the Applet in that case, as it's ineffective (you've got to send thousands of pixels for 1 simple change) and you loose information (what if someone on the other end wants to resize the rectangle created before?)

I'd rather send messages that in essence say "create a rectangle at position x, y with size w, h, border color c1, fill color c2 and border width w". Then the server forwards this message to each client.

This way each client should have the same view of the current state. The advantage is that you only need to send small messages and that you could later add the ability to send "update rectangle 3 to the dimensions w, h".

JoachimSauera at 2007-7-8 1:33:09 > top of Java-index,Java Essentials,Java Programming...
# 7

Ahh, now we know what you are attempting to do it will be much easier to help you.

I will stand by my original comment, you do not want to be sending the "image of the applet" about the place, you want to be sending a "data model" between machines. When someone draws a line, you do not dump the image down the line, instead you say "user X has drawn a line at point x to point y in blue".

mlka at 2007-7-8 1:33:10 > top of Java-index,Java Essentials,Java Programming...
# 8

nice idea ,

now i complete Graphic part and have two questions :

1) if i have 2 client so every client must have the same GUI code in his machine ( copy the java code for graphic in every machine ) ?

2) how i can really appear the affect to the board , when the message forwad to the server and then to other clients

for example : ( client 1 draw rectangle in point x,y with high h and width w ) so iam as a server how can i deal with this message , just forwad it ?

if iam just forwad it so the board will not affect ? or iam must parse the messages and draw the shapes ?

eaajea at 2007-7-8 1:33:10 > top of Java-index,Java Essentials,Java Programming...
# 9

IMHO the layout should be like this:

- Each participant (the server and each client) has a model of the current state of the blackboard (which shapes it contains, who made them, which attributes they have).

- When a client connects to the server, it fetches the current state of the blackboard from the server, to be up-to-date

- When a client makes a change, it sends a message to the server with a description of the change.

- When the server recieves such a change then it forwards a similar message (maybe even the same one) to each connected client (except the one who just sent it, maybe) to update their view as well.

It will be somewhat more complicated as this (especially if you allow modifying existing objects, then you'll handle timestamping and such stuff), but that's the basic idea.

JoachimSauera at 2007-7-8 1:33:10 > top of Java-index,Java Essentials,Java Programming...
# 10

> IMHO the layout should be like this:

>

> - Each participant (the server and each client) has a

> model of the current state of the blackboard (which

> shapes it contains, who made them, which attributes

> they have).

so in my project it will be the applet ( contain ComboBox to draw Shapes , and ComboBox to select the color )

> - When a client connects to the server, it fetches

> the current state of the blackboard from the server,

> to be up-to-date

sorry sir iam not understand this , how the client fetch current state ?

> - When a client makes a change, it sends a message to

> the server with a description of the change.

> - When the server recieves such a change then it

> forwards a similar message (maybe even the same one)

> to each connected client (except the one who just

> sent it, maybe) to update their view as well.

how update the view if iam only sending messages !!

by this way the messages will appear in client then the client draw the shape that describtion in message ,

eaajea at 2007-7-8 1:33:10 > top of Java-index,Java Essentials,Java Programming...
# 11
the server sends datas(size, x, y,...) and the applet interprets them and the shapes
suparenoa at 2007-7-8 1:33:10 > top of Java-index,Java Essentials,Java Programming...