Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: mouse pointer finder?

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    26
    My Mood
    Aggressive
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default mouse pointer finder?

    Untitled.png

    how can i put it this way,
    if the mouse pointer is in the orange region, it will give me 0;
    if the mouse pointer is in green region, it will give me 1;
    in red is 2;
    in violet is 3;

    just a simple top, right, bottom, left;

    i cant make an equation or formula :/

    please help


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: mouse pointer finder?

    Where are you stuck? What did you try?
    How would you do it if the given shape was drawn on graph paper?
    Each region has some relation to it's position and the x,y values
    Post the code for better help, there are too many unknowns in the given problem.

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    26
    My Mood
    Aggressive
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: mouse pointer finder?

    i cant put codes because there's no codes yet at all..

    i think my question is not clear..

    how will i know if the mouse pointer is (45 degrees to 135 degrees) to the center, or exactly where orange region is... there is sin or cosine involved here and i cant do it

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

  5. #5
    Junior Member
    Join Date
    Apr 2013
    Posts
    26
    My Mood
    Aggressive
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: mouse pointer finder?

    ok thanks for that info but how can i convert the angle between my mouse pointer and the center of the jframe to raidans?

  6. #6
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: mouse pointer finder?

    How would you do it without a computer or program?
    If you do not understand rotation in radians, tackle this problem in a way that you understand. There are multiple ways to determine which area the mouse is in.
    How would you do it on graph paper?
    If the mouse is above the middle or below the middle would give you the upper half or lower half... Now you have cut out one possible option, either the top or bottom.
    If the mouse is to the left of center or right of center... Now you cut out either the left or right side leaving only two possible options.
    The only thing left to do is determine which side of the diagonal line the mouse is in, because in all possible cases you are left with a square 1/4 the original size cut in half corner to corner

Similar Threads

  1. change finder
    By Darksole in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 22nd, 2013, 07:35 PM
  2. Problems with my prime finder program
    By Truck35 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: December 9th, 2012, 12:56 PM
  3. Fixing this grade finder program?
    By Stinger25 in forum What's Wrong With My Code?
    Replies: 25
    Last Post: December 4th, 2012, 08:10 AM
  4. Help with my Range Finder programme
    By kidza12 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 3rd, 2011, 01:53 PM
  5. [SOLVED] Recursive Sentence Finder
    By raphytaffy in forum Algorithms & Recursion
    Replies: 4
    Last Post: February 21st, 2010, 02:46 PM