draw line position - networking

S

solomon13000

The code bellow will enable users to scrible anything on a canvas. Now
what I intend to do is to create a vector object for every position
(pre_x,pre_y,x, y) of the lines drawn on the canvas and send it using
a socket connection to a remote server.

public void mouseDragged(MouseEvent e)
{
if(isButtonPressed==true)
{
pre_x=e.getX()+scrollbarH_value;
pre_y=e.getY()+scrollbarV_value;
isButtonPressed=false;
}
x=e.getX()+scrollbarH_value;
y=e.getY()+scrollbarV_value;
offscreenImageG.drawLine( pre_x, pre_y, x, y);
pre_x=x;
pre_y=y;
repaint();
e.consume();
message.setText(pre_x + ":" + pre_y + ":" + x + ":" + y);
}

Is my apporach considered to be feasible?. Any other ways?

Regards.
 
A

Andrew Thompson

The code bellow will enable users to scrible anything on a canvas.

Why are you using AWT in this day and age? If you
are (primarily) using Swing, why are you mixing Swing
with AWT?
..Now what I intend to do is to create a vector

ArrayList (is probably) a better alternative to Vector,
since Java 1.2.
...object for every position
(pre_x,pre_y,x, y) of the lines drawn on the canvas and send it using
a socket connection to a remote server. ...
Is my apporach considered to be feasible?.

By who? I consider it feasible, until you try it and find
it fails because (..insert reason here).
..Any other ways?

Construct the (joined) points into a GeneralPath and send
that, if they are not joined, send an ArrayList of same.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200710/1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top