Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Java Mouse Movement.
sparkx
post Sep 14 2008, 04:43 PM
Post #1


Sparkx
Group Icon

Group: [HOSTED]
Posts: 366
Joined: 11-October 06
From: Dana Point, CA, USA
Member No.: 16,496
myCENTs:44.66



This question is not as easy as you may think to answer, so please read my post completely before replying. 

  I am trying to make an applet that responds to mouse movements but I always have trouble. I can make it work just fine if I find the distance from a point using getX(); or getXOnScreen(); but that's not what I want to do. I want to get the direct input from the mouse. Why? Because when the mouse (cursor) hits the edge of the screen its position stays the same even when you move it. I have tried using a robot to keep the mouse in the center of the screen (setPosition or something like that). But that is just glitch because the robot no longer works when the cursor leaves the window. One possible solution that I haven't gotten to work yet is full screen mode (as in actually full screen not just maximized). This would also solve the problem of accidentally clicking things in the background (not on the game). Any Suggestions?

Please post/link to tutorials, source and/or documentation.

Thanks, 

Sparkx


Go to the top of the page
 
+Quote Post
wutske
post Sep 16 2008, 06:36 PM
Post #2


Way Out Of Control - You need a life :)
Group Icon

Group: [HOSTED]
Posts: 1,087
Joined: 2-August 05
From: Kapellen (Antwerp, Belgium)
Member No.: 7,585



QUOTE(sparkx @ Sep 14 2008, 06:43 PM) *
This question is not as easy as you may think to answer, so please read my post completely before replying. 

  I am trying to make an applet that responds to mouse movements but I always have trouble. I can make it work just fine if I find the distance from a point using getX(); or getXOnScreen(); but that's not what I want to do. I want to get the direct input from the mouse. Why? Because when the mouse (cursor) hits the edge of the screen its position stays the same even when you move it. I have tried using a robot to keep the mouse in the center of the screen (setPosition or something like that). But that is just glitch because the robot no longer works when the cursor leaves the window. One possible solution that I haven't gotten to work yet is full screen mode (as in actually full screen not just maximized). This would also solve the problem of accidentally clicking things in the background (not on the game). Any Suggestions?

Please post/link to tutorials, source and/or documentation.

Thanks, 

Sparkx


The listner probably receives wrong values when the mouse leaves the screen, see if it throws an error.
Go to the top of the page
 
+Quote Post
sparkx
post Sep 24 2008, 11:25 PM
Post #3


Sparkx
Group Icon

Group: [HOSTED]
Posts: 366
Joined: 11-October 06
From: Dana Point, CA, USA
Member No.: 16,496
myCENTs:44.66



That’s not the problem though... You know when your cursor hits the edge of the screen you can't move it any more? Well that makes a problem for me (because you can continue to move the mouse itself just not the cursor). All I am interested in is the direct input from the mouse not the location of the cursor. I don't want the "coded" input that limits the mouse to inside the screen.

Here is an example... you want to move an object lets say a square that is in the center of the java applet. The applet also has a background image (keep in mind it is all 2d so it is simple). To move the square you would click on it and move the mouse, the background would move the opposite direction of the input from the mouse (giving the affect that the square is moving in that direction but it is not actually moving compared to the screen and centered in the applet). This is simple to do but you quickly run into a problem. The cursor is at the edge of the screen but the square is still not were you want it. See the problem?

Any Suggestions?
Thanks,
Sparkx
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. java.lang.NullPointException(4)
  2. Using system date in java... How?(5)
  3. Java Unlimited(14)
  4. Array Sorting(21)
  5. What Are The Advantages Of Java Vs C++?(15)
  6. Need Help: Find Lowest Character Using Java(7)
  7. Download Java Ebooks(15)
  8. Java By Example(8)
  9. Video Streaming In Web Browser Through Java Or Jsp(1)
  10. Looking For A Java IDE(25)
  11. On Why Java Is 'c'ooler!(10)
  12. Other Sound Format Support(3)
  13. Java Phone Book(2)
  14. How To Create Exe File In Java?(13)
  15. How Do I Test A Java Aplication(11)
  1. Mozilla And Java!(2)
  2. Need To Modify Xml Attribute Using Java(4)
  3. Bluetooth And Java(5)
  4. Java Sdk Vs. Java Jdk?(2)
  5. Graphcal User Interfaces In Java(4)
  6. Java Db Help Pls(2)
  7. Loading 3d Models In Java?(2)
  8. Java Applet Loading Error(5)
  9. Setting Up Java Correctly(8)
  10. Java Java.security.accesscontrolexception(6)
  11. Simple Java Question(3)
  12. Java And Sql: Data Mismatch(6)
  13. Java Memory Leak?(2)


 



- Lo-Fi Version Time is now: 5th December 2008 - 12:15 AM