Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-23-2011, 07:19 PM   PM User | #1
Frozen™
New to the CF scene

 
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Frozen™ is an unknown quantity at this point
Need Help With Draggable Box - Java

Hey.
I've been trying to make a box draggable, but I can't seem to get it right. Basically what I thought to do was check if the left mouse is held down, then check if the position of it is over the part I want dragged. Then it subtracts the new position of the mouse from the old position of the box, and adds that to the position of the box.

Code:
    	if(Mouse.isButtonDown(0))
    	{
    		if((x > 2 + dragAmtX) && (x < 2 + width + dragAmtX) && (y > 60 + dragAmtY) && (y < 60 + height + dragAmtY))
    		{
    		dragAmtX = 2 - x;
    		dragAmtY = 60 - y;
    		}
    	}

  //this is going to draw the box
    	drawBorderedRect(2 + dragAmtX, 60 + dragAmtY, 65 + dragAmtX, 72 + dragAmtY, 1, 0xFF3c3c3c, 0x80391BE0);
But it never works.
Help please!
Frozen™ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:05 AM.


Advertisement
Log in to turn off these ads.