how to update my jframe in a server_client game?
<p>I'm working on a server-client game in which I need to update client's JFrame from the server in a specific period.<a href="http://agar.io" rel="nofollow">this is my game</a>
The problem is that the client's JFrame does not update.to be sure,I have rendered the JFrame Submitted by the server and it's OK,but the client's JFrame does not change at all.Here's my code:</p>

<p>my server:</p>

<pre><code>public class main implements java.io.Serializable{

static ArrayList&lt;Socket&gt; allsockets = new ArrayList&lt;&gt;();
static ArrayList&lt;ObjectOutputStream&gt; oos = new ArrayList&lt;&gt;();
static final MainFrame frame=new MainFrame();
static boolean testfirst=false;
private static final long serialVersionUID = 1L;

   public static void main(String[] args)   {

    // TODO Auto-generated method stub
    String name;
    String color;
    Color color1 = null;
    Socket clientsocket=null;
    ServerSocket serversocket=null;
    PrintStream os = null;
    ObjectInputStream is=null;

    try{ 
        serversocket = new ServerSocket(); // don't bind just yet
        serversocket.setReuseAddress(true);
        serversocket.bind(new InetSocketAddress(5555)); // can bind with reuse= true
    }
    catch(IOException e){
        System.out.println(e);
    }

    while(true){
    try {
         clientsocket=serversocket.accept();
         allsockets.add(clientsocket); 
         oos.add(new ObjectOutputStream(clientsocket.getOutputStream()));
         is=new ObjectInputStream(clientsocket.getInputStream());
         os = new PrintStream(clientsocket.getOutputStream());
         try {
            name =(String) is.readObject();
            color=(String) is.readObject();
             try {
                    java.lang.reflect.Field field = Class.forName("java.awt.Color").getField(color);
                    color1 = (Color)field.get(null);
                } catch (Exception e) {
                    color = null; 
                }
             player p=new player();
             frame.addplayer(name, color1,p);

                if(!testfirst){
                    testfirst=true;
                    new Thread(){
                           public void run(){
                               Timer timer=new Timer();

                               timer.scheduleAtFixedRate(new TimerTask() {

                                    @Override
                                    public void run() {
                                        // TODO Auto-generated method stub
                                        System.out.println("timer works");
                                        for(ObjectOutputStream os:oos){
                                            try {
                                                os.writeObject(frame);

                                            } catch (IOException e) {
                                                // TODO Auto-generated catch block
                                                e.printStackTrace();
                                            }
                                        }

                                    }
                                }, 1, 1);
                           }
                        }.start();
                }

             handle h= new handle(is, frame, p);
             h.start();
        } catch (ClassNotFoundException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }



    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
             }          
          } 
       }


    }
</code></pre>

<p>my client:</p>

<pre><code>public class client implements java.io.Serializable {

static private final Lock mutex = new ReentrantLock(true);
private static final long serialVersionUID = 1L;
 static double prevx =0;
 static double prevy=0;
static Timer timer=new Timer();
static ObjectOutputStream os =null;
public static void main(String[]args)  {

     MainFrame frame=new MainFrame();
     Socket clientSocket=null;
     ObjectInputStream is=null;
     String name;
     String color;

     try {
          clientSocket = new Socket("localhost", 5555);
          os = new ObjectOutputStream(clientSocket.getOutputStream());
          is=new ObjectInputStream(clientSocket.getInputStream());
          System.out.println("enter your name:");
          Scanner in1=new Scanner(System.in);
          name=in1.nextLine();
          System.out.println("enter your color:");
          color=in1.nextLine();
          in1.close();
          os.writeObject(name);
          os.writeObject(color);
          refresh ref=new refresh( is, os);
          ref.start();


        } catch (UnknownHostException e) {
          System.err.println("Don't know about host");
        } catch (IOException e) {
          System.err.println("Couldn't get I/O for the connection to host");
        }   
 }}
</code></pre>

<p>the refresh class(which has the responsibility to update client's JFrame)</p>

<pre><code>public class refresh extends Thread{
MainFrame frame;
ObjectInputStream ois;
ObjectOutputStream oos;
Timer timer=new Timer();
double prevx,prevy;
private  Lock mutex = new ReentrantLock(true);
public refresh(ObjectInputStream ois,ObjectOutputStream oos){

    frame=new MainFrame();
    this.ois=ois;
    this.oos=oos;
}
public void run(){

    while(true){
        try {

            frame= (MainFrame) ois.readObject();
            frame.repaint();
            frame.removeMouseMotionListener(mml);
            frame.addMouseMotionListener(mml);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
            frame.setFocusable(true);


        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }


}
MouseMotionListener mml=new MouseMotionListener() {

    @Override
    public void mouseMoved(MouseEvent arg0) {
        // TODO Auto-generated method stub


                             mutex.lock();
                                try {
                                    System.out.println("mouse moved");
                                    oos.writeObject(arg0.getX());
                                    oos.writeObject(arg0.getY());
                                } catch (IOException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                }
                            mutex.unlock(); 

                                             }

    @Override
    public void mouseDragged(MouseEvent arg0) {
        // TODO Auto-generated method stub

    }
};}
</code></pre>

<p>and if needed the handle class(which receives the mouse coordinates from the client)</p>

<pre><code>public class handle extends Thread{
double prevx,prevy;
MainFrame frame;
player myplayer;
ObjectInputStream ois;
double screenwidth,screenheigth;
boolean first=false;
boolean finished = false;
static private final Lock mutex = new ReentrantLock(true);

Thread movethread = new Thread(){

public void run(){
      System.out.println("movethread run");
    try {

        if(Math.abs(prevx-myplayer.xcenter)&gt;1 || Math.abs(prevy - myplayer.ycenter)&gt;1){


        while(Math.abs(prevx-myplayer.xcenter)!=0
                || Math.abs(prevy - myplayer.ycenter)!=0){

             if(prevx&lt;0 || prevx&gt;screenwidth || prevy&lt;0 || prevy&gt;screenheigth)break;


             myplayer.movem(prevx, prevy,mutex);

             frame.repaint();
             System.out.println(myplayer.cp.getCenter());
         }

         finished = true;
    }
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
     }
}};



public handle(ObjectInputStream ois,MainFrame frame,player p) {
    // TODO Auto-generated constructor stub

    this.myplayer=p;
    this.ois=ois;
    this.frame=frame;
    this.screenwidth=frame.getscreenwidth();
    this.screenheigth=frame.getscreenheigth();
}

public void run(){
    System.out.println("handle thread run");

        while(true){

            try {
                 System.out.println("in handle");
                 System.out.println(first);
                prevx= (double) ois.readObject();
                prevy=(double) ois.readObject();

                if(!first){
                System.out.println("movethread started");
                movethread.start();
                first = true;
            }
            else if(first &amp;&amp; finished){

                movethread.run();
            }
            } catch (ClassNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
}
public void update(double x,double y){
    this.prevx=x;
    this.prevy=y;
}}
</code></pre>

<p>Any help would be appreciated.</p>