java.awt.point

Hello EveryoneDoes anyone know where i can find a tutorial on java.awt.point ?Thanks very much for your reply.
[131 byte] By [va97a] at [2007-11-26 20:06:54]
# 1
lol
tjacobs01a at 2007-7-9 23:08:41 > top of Java-index,Desktop,Core GUI APIs...
# 2
It's a data object with two values, x and y.I'm struggling to imagine how anyone could possibly write much of a tutorial about it :o|
itchyscratchya at 2007-7-9 23:08:41 > top of Java-index,Desktop,Core GUI APIs...
# 3
at least something on how to use it ?
va97a at 2007-7-9 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 4

so say I have

x and y

40and 200

20and 100

49and 23

Say the user inputs 40 and clicks a button. I need to tell the program to return 200.

How do i store those 3 x values w/ their corresponding y values ? I have to use java.awt.point. Does point work with arrays or list ?

Message was edited by:

va97

va97a at 2007-7-9 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 5
Does point work with arrays or list ?Er, yes, the same as absolutely any other object. Although, depending on what you're actually doing, you might want to consider a Map<Integer, Integer> instead of a Collection<Point>.
itchyscratchya at 2007-7-9 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 6
It is hard for me to believe that you are serious with these questions. All I can say is that if you are serious, you should either go to office hours or try to get some help from your teacher, or if you're not in a class pick a different career / hobby
tjacobs01a at 2007-7-9 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 7
It certainly gets the award for the most amusingly facile thread in a good while :o)
itchyscratchya at 2007-7-9 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 8

tjacobs01

Some of us are not experts, which is why we seek help to understand some topics that were not covered in class. Topics that the books I have don't discuss much about.

One can't learn everything there is to know about Java.

I am new to this forum so if you don't want to help, by all means you don't have to answer but try not to talk or look down at others.

Thanks

Message was edited by:

va97

va97a at 2007-7-9 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 9
itchyscratchyconsider a Map<Integer, Integer> That's exactly what i told the user but he is adamant about using Point.
va97a at 2007-7-9 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 10

> I am new to this forum so if you don't want to help,

> by all means you don't have to answer but try not to

> talk or look down at others.

va don't get so upset. It's not like I'm laughing with you; I'm laughing at you.

go go go - get your troll on (I should be a rapper or a dj or something)

:)

tjacobs01a at 2007-7-9 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 11

Hopefully, someone can enlighten me ?

I have an array of point

int[] depth = {25, 30, 35, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190};

int[] minutes = {595, 405, 310, 200, 100, 60, 50, 40, 30, 25, 20, 15, 10, 10, 5, 5, 5, 5, 5};

Point[] points = new Point[depth.length];

for(int i = 0; i < points.length; i++)

{

points[i] = new Point(depth[i], minutes[i]);

}

JTextField tfXvalue = new JTextField();

String getXvalue = tfdepth.getText();

Say the input of getXvalue is 40. Then I do all of the necessary conversions from string to double etc...

I need to tell the program to look in the array, and return the Y value where X=40.

I haven't the slightest idea where to start. !!!!

Would someone mind pointing me in the right direction ?

Message was edited by:

va97

va97a at 2007-7-9 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 12
I got it. Thanks you guys
va97a at 2007-7-9 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 13

i'm currently having a problem with my Point array.

after looking at threadstarter program, i'm getting more confused ?

Point[] points = new Point[10];

for(int i = 0; i < 10; i++){

point = new Point(x, y);

}

why did we need to create new instance of the Point the 2nd time?

for example... i can do this

char character = new char[10];

character[0] = 'a';

BUT i can't do the same for

Point point = new Point[10];

point[0].setLocation(x, y);

WHY? i thought that by default the Point value should be (0,0) and yet my compiler threw me an exception :(

meowoa at 2007-7-9 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 14

Because char is a primitive, not a reference. You can think of references as effectively just another type of primitive with a default value of null.

When you're dealing with that Point array, you don't instantiate anything twice. The "new Point[n]" statement instantiates the array object, with space for n references, which must be of type Point, all initially null. The "new Point(x, y)" statement instantiates a Point object, whose reference you then place in one of the n elements of the array.

itchyscratchya at 2007-7-9 23:08:42 > top of Java-index,Desktop,Core GUI APIs...