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.
If i try "int" in that math, the values are then zero for everything
- even those where i do no calculation.
2) Use the calculated integer values as an index to a table or array.
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.
Can this be done, and eXactly how? 17 3580
"Robert Baer" <ro********@ear thlink.net> wrote in message
news:ci******** **********@news read2.news.pas. earthlink.net.. . 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. If i try "int" in that math, the values are then zero for everything - even those where i do no calculation. 2) Use the calculated integer values as an index to a table or array. 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.
Can this be done, and eXactly how?
I didn't understand your question at all. Perhaps you can post an SSCCE? http://mindprod.com/jgloss/sscce.html
Be sure to specify what results you expected your program to produce,
and what results you actually got, and how they differed.
- Oliver
On Thu, 30 Mar 2006 10:20:56 GMT, Robert Baer
<ro********@ear thlink.net> wrote: 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. If i try "int" in that math, the values are then zero for everything - even those where i do no calculation. 2) Use the calculated integer values as an index to a table or array. 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.
Can this be done, and eXactly how?
I'm taking a broad guess here, seeing as how your description is
vague, but...what you probably want is something along the lines of
this:
public MyClass implements MouseMotionList ener {
// constructors and other methods...
// MouseMotionList ener methods
public void mouseMoved(Mous eEvent e) {
Point p = e.getPoint();
doSomeCalculati on(p);
}
public void mouseDragged(Mo useEvent e) {
/* more stuff here if necessary */
}
}
Alternatively, if called from within a class that extends some
subclass of java.awt.Compon ent:
public MyClass extends JFrame {
public MyClass( /* parameters */) {
addMouseMotionL istener(new MouseMotionList ener() {
public void mouseMoved(Mous eEvent e) {
Point p = e.getPoint();
doSomeCalculati on(p);
}
public void mouseDragged(Mo useEvent e) {
/* ... */
}
});
}
}
The doSomeCalculati on(Point p) method could provide, say, a mapping
from regions to elements of a table, e.g. with the java.awt.Rectan gle
contains() method.
Hope this helps; if not, you might want to be more specific!
Evan Stratford
1B CompSci/SoftEng option
University of Waterloo
Oliver Wong wrote: "Robert Baer" <ro********@ear thlink.net> wrote in message news:ci******** **********@news read2.news.pas. earthlink.net.. .
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. If i try "int" in that math, the values are then zero for everything - even those where i do no calculation. 2) Use the calculated integer values as an index to a table or array. 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.
Can this be done, and eXactly how?
I didn't understand your question at all. Perhaps you can post an SSCCE? http://mindprod.com/jgloss/sscce.html
Be sure to specify what results you expected your program to produce, and what results you actually got, and how they differed.
- Oliver
I *thought* i mentioned what i wanted to do, as well as "int" not
only does not work, it kills the reading of mouse XY coordinates.
And i would have no clue as if the code was compilable or not, and i
do not think i care, since the jave code is a part of an HTML web page.
However, i will copy the code i have across from my other OS drive later.
Evan Stratford wrote: On Thu, 30 Mar 2006 10:20:56 GMT, Robert Baer <ro********@ear thlink.net> wrote:
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. If i try "int" in that math, the values are then zero for everything - even those where i do no calculation. 2) Use the calculated integer values as an index to a table or array. 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.
Can this be done, and eXactly how?
I'm taking a broad guess here, seeing as how your description is vague, but...what you probably want is something along the lines of this:
public MyClass implements MouseMotionList ener {
// constructors and other methods...
// MouseMotionList ener methods public void mouseMoved(Mous eEvent e) { Point p = e.getPoint(); doSomeCalculati on(p); }
public void mouseDragged(Mo useEvent e) { /* more stuff here if necessary */ }
}
Alternatively, if called from within a class that extends some subclass of java.awt.Compon ent:
public MyClass extends JFrame {
public MyClass( /* parameters */) { addMouseMotionL istener(new MouseMotionList ener() { public void mouseMoved(Mous eEvent e) { Point p = e.getPoint(); doSomeCalculati on(p); } public void mouseDragged(Mo useEvent e) { /* ... */ } }); }
}
The doSomeCalculati on(Point p) method could provide, say, a mapping from regions to elements of a table, e.g. with the java.awt.Rectan gle contains() method.
Hope this helps; if not, you might want to be more specific!
Evan Stratford 1B CompSci/SoftEng option University of Waterloo
WHat you gave might be useful to someone, but "class"? and "method"?
and why bother to create what might be some kind of a function if a
calculation is neededin only one place?
The "do some calculation" bit is what is troubling; "int" does not
work and kills reading of mouse XY coordinates.
I will copy across the HTML / Java code i have from the OS and drive
it is on, for show.
"Robert Baer" <ro********@ear thlink.net> wrote in message
news:nN******** **********@news read2.news.pas. earthlink.net.. . Oliver Wong wrote:
"Robert Baer" <ro********@ear thlink.net> wrote in message news:ci******** **********@news read2.news.pas. earthlink.net.. .
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. If i try "int" in that math, the values are then zero for everything - even those where i do no calculation. 2) Use the calculated integer values as an index to a table or array. 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.
Can this be done, and eXactly how?
I didn't understand your question at all. Perhaps you can post an SSCCE? http://mindprod.com/jgloss/sscce.html
Be sure to specify what results you expected your program to produce, and what results you actually got, and how they differed.
- Oliver
I *thought* i mentioned what i wanted to do, as well as "int" not only does not work, it kills the reading of mouse XY coordinates. And i would have no clue as if the code was compilable or not, and i do not think i care, since the jave code is a part of an HTML web page. However, i will copy the code i have across from my other OS drive later.
Since the code is "part of an HTML web page", might you be talking about
JavaScript, rather than Java?
- Oliver
Robert Baer wrote: Evan Stratford wrote:
On Thu, 30 Mar 2006 10:20:56 GMT, Robert Baer <ro********@ear thlink.net> wrote:
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. If i try "int" in that math, the values are then zero for everything - even those where i do no calculation. 2) Use the calculated integer values as an index to a table or array. 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.
Can this be done, and eXactly how?
I'm taking a broad guess here, seeing as how your description is vague, but...what you probably want is something along the lines of this:
public MyClass implements MouseMotionList ener {
// constructors and other methods...
// MouseMotionList ener methods public void mouseMoved(Mous eEvent e) { Point p = e.getPoint(); doSomeCalculati on(p); }
public void mouseDragged(Mo useEvent e) { /* more stuff here if necessary */ }
}
Alternatively, if called from within a class that extends some subclass of java.awt.Compon ent:
public MyClass extends JFrame {
public MyClass( /* parameters */) { addMouseMotionL istener(new MouseMotionList ener() { public void mouseMoved(Mous eEvent e) { Point p = e.getPoint(); doSomeCalculati on(p); } public void mouseDragged(Mo useEvent e) { /* ... */ } }); }
}
The doSomeCalculati on(Point p) method could provide, say, a mapping from regions to elements of a table, e.g. with the java.awt.Rectan gle contains() method.
Hope this helps; if not, you might want to be more specific!
Evan Stratford 1B CompSci/SoftEng option University of Waterloo WHat you gave might be useful to someone, but "class"? and "method"? and why bother to create what might be some kind of a function if a calculation is neededin only one place? The "do some calculation" bit is what is troubling; "int" does not work and kills reading of mouse XY coordinates. I will copy across the HTML / Java code i have from the OS and drive it is on, for show.
Can't you just grab the coordinates from the Point?
Method is another name for member function...
What exactly do you mean by "'class'?"?
Don't you know what a class is?
Anyway,
if you don't want to use a function, then just put the content of the
function where he used one...
Robert Baer wrote: Evan Stratford wrote:
On Thu, 30 Mar 2006 10:20:56 GMT, Robert Baer <ro********@ear thlink.net> wrote:
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. If i try "int" in that math, the values are then zero for everything - even those where i do no calculation. 2) Use the calculated integer values as an index to a table or array. 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.
Can this be done, and eXactly how?
I'm taking a broad guess here, seeing as how your description is vague, but...what you probably want is something along the lines of this:
public MyClass implements MouseMotionList ener {
// constructors and other methods...
// MouseMotionList ener methods public void mouseMoved(Mous eEvent e) { Point p = e.getPoint(); doSomeCalculati on(p); }
public void mouseDragged(Mo useEvent e) { /* more stuff here if necessary */ }
}
Alternatively, if called from within a class that extends some subclass of java.awt.Compon ent:
public MyClass extends JFrame {
public MyClass( /* parameters */) { addMouseMotionL istener(new MouseMotionList ener() { public void mouseMoved(Mous eEvent e) { Point p = e.getPoint(); doSomeCalculati on(p); } public void mouseDragged(Mo useEvent e) { /* ... */ } }); }
}
The doSomeCalculati on(Point p) method could provide, say, a mapping from regions to elements of a table, e.g. with the java.awt.Rectan gle contains() method.
Hope this helps; if not, you might want to be more specific!
Evan Stratford 1B CompSci/SoftEng option University of Waterloo WHat you gave might be useful to someone, but "class"? and "method"? and why bother to create what might be some kind of a function if a calculation is neededin only one place? The "do some calculation" bit is what is troubling; "int" does not work and kills reading of mouse XY coordinates. I will copy across the HTML / Java code i have from the OS and drive it is on, for show.
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...
Robert Baer wrote: 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. If i try "int" in that math, the values are then zero for everything - even those where i do no calculation. 2) Use the calculated integer values as an index to a table or array. 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.
Can this be done, and eXactly how?
Here is the code i have so far:
<html code starts here; this is altered to help protect some>
<head>
<title>Test page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet " type="text/css" href="style.css ">
</head>
<!--
var with "Netscape" makes Netscape happy
adding "int" or "integer" in any way totally kills operation
-->
<SCRIPT LANGUAGE="JavaS cript">
<!--
var isNav = (navigator.appN ame.indexOf("Ne tscape") !=-1);
function handlerMM(e){
Xmm = (isNav) ? e.pageX : event.clientX;
Ymm = (isNav) ? e.pageY : event.clientY;
document.dataho lder.mmX.value= ((Xmm-173)/6.8+1938);
document.dataho lder.mmY1.value =Ymm;
document.dataho lder.mmY2.value =Xmm;
document.dataho lder.mmZ.value= ((Xmm-173)/6.8+1938);
}
if (isNav) {
document.captur eEvents(Event.M OUSEMOVE);
}
document.onmous emove = handlerMM;
// -->
</SCRIPT>
<body>
<center>
<form name="dataholde r">
<table border=1>
<tr>
<td><i>Year(wid e)</i></td>
<td><input type="text" size=9 name="mmX" value="0"></td>
<td><i>Year(nar row)</i></td>
<td><input type="number" size=3.8 name="mmX" value="0"></td>
<td><i>Number of wells</i></td>
<td><input type="text" size=5 name="mmY1" value="0"></td>
<td><i>Producti on BBLs</i></td>
<td><input type="text" size=5 name="mmY2" value="0"></td>
<td><i>Z value</i></td>
<td><input type="text" size=9 name="mmZ" value="0"></td>
</tr>
</table>
</form>
</div>
<!--
This code *used to* work, showing a calculated year in the first 2
boxes; the width
of the second box was made narrow to visually "truncate" the
numbers to integer.
I have no idea as to why they no longer work.
I added "Z value" and *that* works (!!). Go figure.
-->
<table align="center">
<tr>
<td align=center>
<center>
<div><i>© 2006 Oil 4 Less LLC</i></div>
</center>
</td>
</tr>
</table>
<!-- style and then img src as seperate items makes IE happy; GIF
is 90% BMP -->
<div style="position : absolute; height: 316px; width: 697px; top: 100px;
left: 20px; "
<style="heigh t: 316px; width: 697px; top: 100px; left: 20px; " >
<img src="Arkansas.g if" alt="" usemap="#AK" style="border-style:none" >
</div>
</body>
</html>
Robert Baer wrote: Robert Baer wrote:
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. If i try "int" in that math, the values are then zero for everything - even those where i do no calculation. 2) Use the calculated integer values as an index to a table or array. 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.
Can this be done, and eXactly how? Here is the code i have so far: <html code starts here; this is altered to help protect some> <head> <title>Test page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet " type="text/css" href="style.css "> </head>
<!-- var with "Netscape" makes Netscape happy adding "int" or "integer" in any way totally kills operation --> <SCRIPT LANGUAGE="JavaS cript"> <!-- var isNav = (navigator.appN ame.indexOf("Ne tscape") !=-1); function handlerMM(e){ Xmm = (isNav) ? e.pageX : event.clientX; Ymm = (isNav) ? e.pageY : event.clientY; document.dataho lder.mmX.value= ((Xmm-173)/6.8+1938); document.dataho lder.mmY1.value =Ymm; document.dataho lder.mmY2.value =Xmm; document.dataho lder.mmZ.value= ((Xmm-173)/6.8+1938); } if (isNav) { document.captur eEvents(Event.M OUSEMOVE); } document.onmous emove = handlerMM; // --> </SCRIPT>
<body> <center> <form name="dataholde r"> <table border=1> <tr> <td><i>Year(wid e)</i></td> <td><input type="text" size=9 name="mmX" value="0"></td> <td><i>Year(nar row)</i></td> <td><input type="number" size=3.8 name="mmX" value="0"></td> <td><i>Number of wells</i></td> <td><input type="text" size=5 name="mmY1" value="0"></td> <td><i>Producti on BBLs</i></td> <td><input type="text" size=5 name="mmY2" value="0"></td> <td><i>Z value</i></td> <td><input type="text" size=9 name="mmZ" value="0"></td> </tr> </table> </form> </div>
<!-- This code *used to* work, showing a calculated year in the first 2 boxes; the width of the second box was made narrow to visually "truncate" the numbers to integer. I have no idea as to why they no longer work. I added "Z value" and *that* works (!!). Go figure. -->
<table align="center"> <tr> <td align=center> <center> <div><i>© 2006 Oil 4 Less LLC</i></div> </center> </td> </tr> </table>
<!-- style and then img src as seperate items makes IE happy; GIF is 90% BMP --> <div style="position : absolute; height: 316px; width: 697px; top: 100px; left: 20px; " <style="heigh t: 316px; width: 697px; top: 100px; left: 20px; " > <img src="Arkansas.g if" alt="" usemap="#AK" style="border-style:none" > </div>
</body> </html>
Yeah,
this is JavaScript,
which basically has nothing to do with Java...
I believe there is some Object Orientation in it,
but not as advanced as Java's.
I'd recommend you go to the comp.lang.javas cript group instead, or a
similar one... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Elijah Bailey |
last post by:
I have two char arrays of size k.
I want to know which one is bigger (exactly like for instance
I compare two ints/longs/etc.).
What is the fastest way to do this? k <= 10 usually for my application.
I tried bcmp / a loop for comparison, but it seems they are very slow
compared to comparing longs...Any ideas?
I tried splitting the array into longs and comparing, but then
I face the high endian/low endian problem on some machines.
|
by: aruna |
last post by:
Given a set of integers, how to write a program in C
to sort these set of integers using C, given the following conditions
a. Do not use arrays
b. Do not use any comparison function like if/then
or switch-case
c. you can use pointers only
d. you cannot use any of the loops either.
|
by: Paul Morrison |
last post by:
Hi all,
I need to come up with some differences between arrays in Java and C, I have
searched Google and so far all I have found is the following:
Arrays in Java are reference types with automatic allocation of memory. In
C, arrays are groups of variables of the same type in adjacent memory.
Allocation for dynamic arrays is handled by the programmer.
This is an 8 mark question in an old exam paper, so I am assuming there are
|
by: John Bend |
last post by:
Hello.
Can anyone please suggest some good tutorial links where Java Vectors
and Arrays are explained and compared?
I'm a proficient programmer but fairly new to Java. Whilst I understand
arrays I don't fully understand Vectors and when to use them.
Many thanks.
|
by: Rob Griffiths |
last post by:
Can anyone explain to me the difference between an element type and a
component type?
In the java literature, arrays are said to have component types, whereas
collections from the Collections Framework are said to have an element
type.
http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html
| |
by: Robert Baer |
last post by:
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.
If i try "int" in that math, the values are then zero for everything...
|
by: susheela s |
last post by:
Hi,
Im doing a multiplication of two large integers which are store in arrays(such as 2345 is in array as 2 in a, 3 in a and so on)like this im storing integers in two arrays.The logic i have used is explained with code below,
class large{
int no; //array is used to store the large number. Each digit of a the number is stored as an element..
// 123 is stored as no={1,2,3}
public:
large operator *(large& x){ // overload...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |