• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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.
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic