drag and drop cannot drop in my layer java -


i have problem label when drag it. i'm using jlayerpane. label didn't want dropped layer. code.am wrong code?

preview error

http://i.stack.imgur.com/vvpa2.jpg

http://i.stack.imgur.com/mzh8q.jpg

this global variable

cursor draggingcursor = cursor.getpredefinedcursor(cursor.hand_cursor); point anchorpoint; private int xoffset; private int yoffset; private jlabel draggy; private string oldtext; 

and jlabel.event mouse released

 private void jlabel1mousereleased(java.awt.event.mouseevent evt) {                                           if (draggy != null) {             draggy.settext(oldtext);             draggy.setsize(draggy.getpreferredsize());             draggy = null;         }     draggy.setlocation(evt.getx() - xoffset, evt.gety() - yoffset); }           

and mousepressed event

private void jlabel1mousepressed(java.awt.event.mouseevent evt) {                                          jcomponent comp = (jcomponent) evt.getcomponent();         component child = comp.findcomponentat(evt.getpoint());         if (child instanceof jlabel) {             xoffset = evt.getx() - child.getx();             yoffset = evt.gety() - child.gety();              draggy = (jlabel) child;             oldtext = draggy.gettext();             draggy.settext("what drag");             draggy.setsize(draggy.getpreferredsize());         } } 

and when mouse dragged

private void jlabel1mousedragged(java.awt.event.mouseevent evt) {                                          if (draggy != null) {             draggy.setlocation(evt.getx() - xoffset, evt.gety() - yoffset);         } } 


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -