Re: integers and arrays in Java - how?
- From: Sigmund Hansen <sigmunha@xxxxxxxxxxxxxxxxx>
- Date: Mon, 03 Apr 2006 21:53:26 +0200
Ian Shef wrote:
Sigmund Hansen <sigmunha@xxxxxxxxxxxxxxxxx> wrote in news:qsbXf.8452$zc1.6768
@amstwist00:
Oh yeah, I forgot:
to get the X and Y coordinates just use:
snippety snippety snip ...
Point p = e.getPoint();
int x = p.getX();
int y = p.getY();
snippety ...
The getX and getY functions will return the ints of the Point you got from the mouseEvent in Evan's code...
Wrong! Sorry, but I just got caught by this the other day.
The methods getX() and getY() in java.awt.Point each return a double !
Your code should look more like:
Point p = e.getPoint();
int x = p.x;
int y = p.y;
x and y are public int fields of Point.
Yeah I noticed that a bit later,
but figured it was a bit late to post another correction...
Didn't know they were public, but that might explain why it has integer coordinates whose get methods return doubles...
Anyway,
it doesn't apply to this because he's coding JavaScript...
(BTW, I haven't actually coded in years, so my memory on classes and functions in even the standard API is kind of nasty, and for that matter deprecated.
But I'm starting back up now, trying to learn some LWJGL and such, hopefully it will be fun, and not just time consuming (time being something I don't have a lot of))... ;)
.
- References:
- Re: integers and arrays in Java - how?
- From: Ian Shef
- Re: integers and arrays in Java - how?
- Prev by Date: Re: integers and arrays in Java - how?
- Next by Date: Re: Double buffer help
- Previous by thread: Re: integers and arrays in Java - how?
- Next by thread: Re: integers and arrays in Java - how?
- Index(es):
Relevant Pages
|
|