java - How to make image which can be dragged in JFrame -


this program suppose make image draggable in jframe .

package testing;   import java.io.*; import java.util.*; import java.security.*; import javax.xml.bind.datatypeconverter; import java.lang.*; import java.awt.*; import javax.swing.*; import  java.awt.event.*;  public class testing  {      static class cpanel extends jpanel     {        cpanel()        {            this.setpreferredsize(new dimension(200,100));             icon = new imageicon("./src/testing/cal.png");             jl = new jlabel(icon);             this.add(jl);         }         class cmotionlistener implements mousemotionlistener        {            public void mousemoved(mouseevent event)            {             }             public void mousedragged(mouseevent event)            {             }           }           jlabel jl ;        imageicon icon;     }       public static void main(string[] args)      {         jframe jf = new jframe();         jf.setpreferredsize(new dimension(1000,1000));          cpanel cp = new cpanel();            jf.add(cp);         jf.pack();         jf.setvisible(true);       }   } 

cmotionlistener implements mousemotionlistener , method mousedragged supposed overridden when clicked on image , dragged , dragged along mouse .

my problem unsure how go overriding method mousedragged image can dragged along mouse .


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -