Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

Need to invert x-value of mouse

Thread view: 
lannsjo@home.se - 22 May 2006 15:41 GMT
Hi,
Someone that can figure out a smart way to invert my mousepointer's
x-axis.

I have this function:

doMyFancyStuff(mouseXpos,mouseYpos);

but I want mouseXpos to be inverted... i.e 800 should be 1 and 1 should
be 800 (if my screen resolution is 800..)
Ingo R. Homann - 22 May 2006 15:54 GMT
Hi,

> Hi,
> Someone that can figure out a smart way to invert my mousepointer's
[quoted text clipped - 6 lines]
> but I want mouseXpos to be inverted... i.e 800 should be 1 and 1 should
> be 800 (if my screen resolution is 800..)

I'm not sure if I understand your problem correctly, because if I do
understand you correctly, the problem would be trivial and I would
suggest you give up programming when you do not get the solution by
yourself:

doMyFancyStuff(800-mouseXpos+1,mouseYpos);

Or do you want to know how to get the screen-resolution? That should be
something like:

Toolkit.getDefaultToolkit().getScreenResolution();

BTW: Computers start counting with 0, so you have an off-by-1-error.

Ciao,
Ingo
jmcgill - 22 May 2006 19:06 GMT
> doMyFancyStuff(800-mouseXpos+1,mouseYpos);

Now THAT is a bad idea, putting a magic number in there, where it only
works in one specific case.

This is a job for Graphics2D.transform().  Don't compute the
coordinates, change the origin.
Ingo R. Homann - 23 May 2006 09:59 GMT
Hi,

>> doMyFancyStuff(800-mouseXpos+1,mouseYpos);
>
> Now THAT is a bad idea, putting a magic number in there, where it only
> works in one specific case.

I know that. That's why I wrote the rest of my posting (that you snipped).

> [snipped another good idea ;-]

Ciao,
Ingo
Thomas Fritsch - 22 May 2006 16:06 GMT
> Hi,
> Someone that can figure out a smart way to invert my mousepointer's
[quoted text clipped - 6 lines]
> but I want mouseXpos to be inverted... i.e 800 should be 1 and 1 should
> be 800 (if my screen resolution is 800..)
I don't see how a "screen resolution" might come in here. You probably mean
"screen width" (in dots), not "screen resolution" (in dots per inch).
BTW: You can get it with Toolkit.getDefaultToolkit().getScreenSize().width
Signature

Thomas

Oliver Wong - 25 May 2006 16:51 GMT
>> Hi,
>> Someone that can figure out a smart way to invert my mousepointer's
[quoted text clipped - 11 lines]
> "screen width" (in dots), not "screen resolution" (in dots per inch).
> BTW: You can get it with Toolkit.getDefaultToolkit().getScreenSize().width

   I don't know about the etymological correctness of the term, but
nowadays "screen resolution" often refers to the number of pixels a screen
can display. See, for example,
http://en.wikipedia.org/wiki/Screen_resolution

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.