Link to home
Start Free TrialLog in
Avatar of amba2004
amba2004

asked on

How do I add a label

How do I add a label to a canvas and move the label with the mouse on every mouseDragged event.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

label.setPosition(me.getX(), me.getY()); // 'me' is the MouseEvent
Use a null layout, and set the label location in your mouseDragged.

label.setLocation(event.getX(), event.getY());
>How do I add a label to a canvas
You *cannot* add Label to a Canvas since Canvas is not a Container.
ASKER CERTIFIED SOLUTION
Avatar of gnoon
gnoon
Flag of Thailand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:)