Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By eRaaaa

Thread: How to get Line Selected

  1. #1
    AryanArs is offline Member
    Join Date
    Feb 2012
    Posts
    9
    Rep Power
    0

    Default How to get Line Selected

    When i click near the line line gets selected but i want the line to be selected when exactly i click on the line not outside the line...I tried with the following code but line gets selected when i click outside, here mouseX and mouseY are the position where i click mouse;
    so help please;


    Line2D.Double ln = new Line2D.Double(xPos,yPos,xPos2,yPos2);

    Java Code:
    boolean isSelected(double mouseX, double mouseY) 
    	{
    		if (mouseX > (xPos - xPos2) && mouseX < (xPos + xPos2) &&
    				   mouseY > (yPos - yPos2) && mouseY < (yPos + yPos2))
    				selected = true;
    		else
    				selected = false;
    		return selected;
    	}

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default Re: How to get Line Selected

    Line2D.Double (Java Platform SE 6)
    Line2D (Java Platform SE 6)

    boolean isSelected(double mouseX, double mouseY)
    {
    return ln.ptSegDist(mouseX,mouseY) == 0.0; //or maybe +- x
    }
    Fubarable likes this.

  3. #3
    AryanArs is offline Member
    Join Date
    Feb 2012
    Posts
    9
    Rep Power
    0

    Default Re: How to get Line Selected

    Thanks Lot...It Worked Nicely..

Similar Threads

  1. Replies: 16
    Last Post: 09-17-2011, 03:41 AM
  2. Replies: 1
    Last Post: 02-13-2011, 04:09 PM
  3. tracing java application line by line using netbeans
    By chandrasekhar123 in forum NetBeans
    Replies: 1
    Last Post: 08-03-2010, 03:46 PM
  4. Replies: 2
    Last Post: 07-02-2010, 03:20 PM
  5. Replies: 4
    Last Post: 09-10-2009, 11:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •