aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
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
Author

help me how to move image ( jpanel)

zaki sat
Greenhorn

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
Greenhorn

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

Joined: May 03, 2008
Posts: 4642
    
    5

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: http://www.oracle.com/technetwork/java/codeconvtoc-136057.html

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help me how to move image ( jpanel)