Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Need some advice/help on an assignment

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Thanked 0 Times in 0 Posts

    Default Need some advice/help on an assignment

    Working on the last assignment in my Java programming class and I am having an issue. The project is a combination of an earlier project combined with networking.

    Earlier we created a Tangram program where you can move pieces and form shapes with them and so on. Now we have to combine that project with networking and have two people move pieces. Here is the description page for the assignment: P6

    The way I am handling the assignment is by sending MouseEvents to the other user when they move a piece. The other user will then receive this MouseEvent and pass it in the appropriate function that will update the corresponding piece on their program. I know that it works because just for testing purposes, I set up one side to only send events and the other to only receive. The problem I am having is trying to make them work back and forth, going both ways. Here is some code showing how one side receives and handles it:

    	public void processConnection() throws IOException
    			event = (MouseEvent) input.readObject();
    			if (event.getID() == 501) // Mouse Pressed
    			if (event.getID() == 506) // Mouse dragged
    			if (event.getID() == 502) // Mouse Released
    		 catch ( ClassNotFoundException classNotFoundException ) 
    		} while (ClientActive != false);
    The code above is the code that solely handles incoming input, and it works if I dedicate the other side to solely sending output. When I try to make the code equal on both sides, to make the server and client simultaneously send/receive output and input, it doesn't work. This makes me think I need some kind of thread that will work independently to send output while the above function will handle the inputs. Would this make any sense?

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 636 Times in 540 Posts

    Default Re: Need some advice/help on an assignment

    What exactly do you mean by "it doesn't work"?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Need some serious advice
    By Rituparna in forum The Cafe
    Replies: 4
    Last Post: September 25th, 2013, 08:26 AM
  2. assignment troubles polymorphism (guide for assignment included)
    By tdawg422 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 8th, 2011, 10:01 AM
  3. need for some advice
    By kasiopi in forum AWT / Java Swing
    Replies: 6
    Last Post: January 26th, 2011, 10:34 AM
  4. A little advice please:
    By SDKC in forum Java Theory & Questions
    Replies: 1
    Last Post: December 8th, 2010, 08:15 PM
  5. i need some advice ....
    By mdstrauss in forum Java Theory & Questions
    Replies: 8
    Last Post: July 24th, 2009, 02:29 PM