This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes help me how to move image ( jpanel) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "help me how to move image ( jpanel)" Watch "help me how to move image ( jpanel)" New topic

help me how to move image ( jpanel)

zaki sat

Joined: May 06, 2012
Posts: 2
i choose image ( jfilechooser) and draw it in jpanel ,but how to move image with mouse ??

my code:

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
add the image to a label
add the label to a panel with null layout
add mouselistener and mousemotionlistener to the label
in mousepressed get the offset of the pointer
in mousedragged reset the labels location
use code tags when posting code
do not post 100's of lines of code
do not pass go
do not collect $200
zaki sat

Joined: May 06, 2012
Posts: 2
ok thanks
Darryl Burke

Joined: May 03, 2008
Posts: 4986

Do UseCodeTags <-- link I've added them for you this time.
Do follow standard coding conventions: variable names should start with a lowercase letter.
Do adopt and follow a standard bracing and indentation style.
-- link:

Do remove excess blank lines and commented lines that have no relevance to the present problem.
Do learn about encapsulation; don't have all fields public.
Do learn about the SSCCE <-- link which always helps you to get better help sooner.

luck, db
There are no new questions, but there may be new answers.
Have you checked out Aspose?
subject: help me how to move image ( jpanel)
It's not a secret anymore!