• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help me how to move image ( jpanel)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i choose image ( jfilechooser) and draw it in jpanel ,but how to move image with mouse ??

my code:

 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok thanks
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic