Re: integers and arrays inJava - how?
- From: "Rhino" <no.offline.contact.please@xxxxxxxxxx>
- Date: Thu, 30 Mar 2006 09:06:10 -0500
"Robert Baer" <robertbaer@xxxxxxxxxxxxx> wrote in message
news:8uOWf.10286$Bj7.8566@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I used Google and found some references for integer in Java.
But "int" not only does not work, it also prevents reading X and Y
coordinates of the mouse.
What i would like to do:
1) Get X and Y mouse coordinates into a variable that i can do real math
on.
So far, i can do math on the values "read" and that result goes into a
"variable" that is useful *only* for display.
Have you looked at
http://java.sun.com/docs/books/tutorial/uiswing/events/mousemotionlistener.html?
This article from the Java Tutorial tells you how to determine the
coordinates of the mouse and expresses those coordinates as separate ints
for the x and y values. Those ints are _not_ "display-only".
Is it possible that you are using the Integer class when you should be using
ints? Otherwise, I'm not sure how you can be having trouble....
If i try "int" in that math, the values are then zero for everything -
even those where i do no calculation.
You need to show us some code so that we can figure out why your
calculations all result in zeroes.
2) Use the calculated integer values as an index to a table or array.
You can use an _int_ as an index to an array without difficulty; you can
even use an Integer if you convert it to an int first. You may be able to
access a table with an int (or an Integer that has been converted to an int)
but it depends on how the table is defined.
It is acceptable to use an HTML "table" as the source for the lookup;This sounds like wording from a homework assignment but it is pretty cryptic
W(CalcFromX) and P(CalcFromX) would be the resulting values to be
displayed on the screen somewhere.
when taken out of context: I don't know whether the question envisions
reading data from an HTML table that is being displayed on a web page
somewhere or whether it proposes reading the source code for the web page;
those are two vastly different things.
You need to describe what you're doing more fully before people can
reasonably hope to answer you.
Can this be done, and eXactly how?
If this is a homework assignment, I'm reasonably sure that it _can_ be done;
most instructors would not waste your time and theirs asking you to do
something that can't be done.
How to do it depends on exactly what you are doing. That isn't clear yet. If
you post the entire homework assignment and then state your questions more
clearly, we can probably answer those questions. But don't expect anyone to
do your homework for you. We will help with information or hints to get you
past a trouble spot but we won't do the assignment for you.
--
Rhino
.
- Follow-Ups:
- Re: integers and arrays inJava - how?
- From: Oliver Wong
- Re: integers and arrays inJava - how?
- References:
- integers and arrays inJava - how?
- From: Robert Baer
- integers and arrays inJava - how?
- Prev by Date: Re: Timer as an inner class
- Next by Date: Re: Timer as an inner class
- Previous by thread: integers and arrays inJava - how?
- Next by thread: Re: integers and arrays inJava - how?
- Index(es):
Relevant Pages
|