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.


>> REGISTER NOW TO START POSTING


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

Page 4 of 4 FirstFirst ... 234
Results 76 to 86 of 86

Thread: drawLine problem, lines not connected

  1. #76
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,319
    Thanks
    56
    Thanked 2,374 Times in 2,345 Posts

    Default Re: drawLine problem, lines not connected

    I don't know the syntax?
    Write the simple program and work out the syntax problems there. It will be easier to post code with problems if its a short simple program.

    Read the API doc to see how to use the methods and constructors for the classes being used.
    What method/class are you having problems with?
    If you don't understand my answer, don't ignore it, ask a question.

  2. #77
    Member
    Join Date
    Sep 2012
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drawLine problem, lines not connected

    I honestly have no idea.
    I don't know how to access the X and Y coordinates from the Point instance while they're in that arrayList element.


    that's it.

  3. #78
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,319
    Thanks
    56
    Thanked 2,374 Times in 2,345 Posts

    Default Re: drawLine problem, lines not connected

    The Point class's x and y variables are public. Get x by: refToPoint.x

    If you aren't going to write a test class to learn how to use the ArrayList and Point classes, there is not much more I can suggest.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #79
    Member
    Join Date
    Sep 2012
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drawLine problem, lines not connected

    Well thanks anyways. I can't learn like others learn, looking at API docs and trying these "simple" programs to test class features and such. I need to see relevant examples in terms of my own code, that's why i asked you multiple times where and how you did things, but as every person I ask for any programming help, you try to get me to do it myself which doesn't ever happen for me when I'm working with a new programming language such as Java, I need to be shown where and how things are done.

    Idk how to get this thread locked but that'd be nice, I'm done with my question.
    Last edited by crzybldthrwr; September 3rd, 2012 at 06:08 PM.

  5. #80
    Member
    Join Date
    Sep 2012
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drawLine problem, lines not connected

    Languages like C++ and VB which I know pretty well I can do things by myself and solve issues by myself.

    But java is new to me and I can't do that.

    edit: Thanks for you help though, I did learn a few things
    Last edited by crzybldthrwr; September 3rd, 2012 at 06:19 PM.

  6. #81
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: drawLine problem, lines not connected

    Quote Originally Posted by crzybldthrwr View Post
    Well thanks anyways. I can't learn like others learn, looking at API docs and trying these "simple" programs to test class features and such. I need to see relevant examples in terms of my own code, that's why i asked you multiple times where and how you did things, but as every person I ask for any programming help, you try to get me to do it myself which doesn't ever happen for me when I'm working with a new programming language such as Java, I need to be shown where and how things are done.

    Idk how to get this thread locked but that'd be nice, I'm done with my question.
    Try not to get discouraged amigo. Norm offers good advice.
    When your problem is too large and you do not understand how something works, put your entire project on hold. Go off to the side and make a new program to play with the new parts. Like was suggested, create a class and fill an arraylist with point objects. A line of code like:
    int myX = myArrayList[myIndex].getX();
    will get the x value of the point object stored at myIndex of myArrayList.

  7. #82
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,319
    Thanks
    56
    Thanked 2,374 Times in 2,345 Posts

    Default Re: drawLine problem, lines not connected

    You will have to learn to read the API doc and use it. That's where everything is defined. And there are often examples of how to use a class. If it's not there it probably doesn't exist.

    Here's a link into the java tutorials:
    The Really Big Index


    I often create small test programs to figure out how a class works. That keeps the other parts of a large program from distracting me.

    Also its important when testing to have controlled input. You want to have the same values going into a program so the output is recognized and consistent. Trying to use live mouse movements for testing would only add uncertainty.
    Last edited by Norm; September 3rd, 2012 at 07:02 PM.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #83
    Member
    Join Date
    Sep 2012
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: drawLine problem, lines not connected

    Quote Originally Posted by jps View Post
    Try not to get discouraged amigo. Norm offers good advice.
    When your problem is too large and you do not understand how something works, put your entire project on hold. Go off to the side and make a new program to play with the new parts. Like was suggested, create a class and fill an arraylist with point objects. A line of code like:
    int myX = myArrayList[myIndex].getX();
    will get the x value of the point object stored at myIndex of myArrayList.
    Thats the main issue I had was that when I used that command jps, it tells me "array found, but arraylist required"

  9. #84
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: drawLine problem, lines not connected

    That sounds like an error where you passed an array to a method expecting an arraylist. Without the code and/or the exact error message, (should post both always) it is hard to say...

  10. #85
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,319
    Thanks
    56
    Thanked 2,374 Times in 2,345 Posts

    Default Re: drawLine problem, lines not connected

    I think this could be the problem:
    int myX = myArrayList[myIndex].getX();
    if it were coded:
    int myX = myArray[myIndex].getX();
    where myArray was an array it should work.
    With an arraylist it should be:
    int myX = myArrayList.get(myIndex).getX();
    If you don't understand my answer, don't ignore it, ask a question.

  11. The Following User Says Thank You to Norm For This Useful Post:

    jps (September 3rd, 2012)

  12. #86
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: drawLine problem, lines not connected

    Quote Originally Posted by Norm View Post
    I think this could be the problem:
    int myX = myArrayList[myIndex].getX();
    if it were coded:
    int myX = myArray[myIndex].getX();
    where myArray was an array it should work.
    With an arraylist it should be:
    int myX = myArrayList.get(myIndex).getX();
    Good call. I wrote that all wrong originally. Thanks Norm.

Page 4 of 4 FirstFirst ... 234

Similar Threads

  1. help with keeping client connected to server
    By frozen java in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 19th, 2011, 02:29 PM
  2. Problem with printing out collinear lines!
    By rkrajnov in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 25th, 2011, 06:32 PM
  3. Problem with Output # of lines
    By coyboss in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 7th, 2011, 10:21 PM
  4. Why rs...still connected
    By javamula in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 30th, 2011, 04:53 PM
  5. g.drawLine doesn't draw line in for loop
    By shumpi in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 12th, 2010, 07:15 PM