Re: integers and arrays inJava - how?




"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;
W(CalcFromX) and P(CalcFromX) would be the resulting values to be
displayed on the screen somewhere.

This sounds like wording from a homework assignment but it is pretty cryptic
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


.



Relevant Pages

  • Re: fread()
    ... > int i,istat,iaccum,intype; ... reading binary data from standard input? ... Use sizeof (float), or even better, sizeof *floatarray, instead. ... FLOAT, and set istat accordingly? ...
    (comp.lang.c)
  • Re: Opening a PPM file Image
    ... Just create a CFile object and open it in binary mode for reading, ... int height; ... int rowsize = width; ...
    (microsoft.public.vc.mfc)
  • Re: frustrated by fscanf and sscanf
    ... no threads talking about reading a series of numbers. ... The input files, somehow structured, is exemplified below: ... int SIZE; ... Reading 2 12X12 arrays of double. ...
    (comp.lang.c)
  • Problem with shared library generated on Solaris 8 X86
    ... trondn@solsrv2 cctest> uname -a ... Reading testprog ... extern int func; ...
    (comp.unix.solaris)
  • Re: Rookie Student C++ Array question (reading from a file)
    ... >>stars for the number of times the number occurred (a histogram). ... but the output is telling me no cigar. ... >>int main{ ... >> It's reading fine from the data file. ...
    (alt.comp.lang.learn.c-cpp)