Re: drawLine problem, lines not connected
Quote:
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?
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.
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.
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.
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
Re: drawLine problem, lines not connected
Quote:
Originally Posted by
crzybldthrwr
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.
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.
Re: drawLine problem, lines not connected
Quote:
Originally Posted by
jps
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"
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...
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();
Re: drawLine problem, lines not connected
Quote:
Originally Posted by
Norm
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.