• 拖拽控件java版


    Button vv = new Button("vvvv");
      DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(vv, DnDConstants.ACTION_MOVE, new DragGestureListener(){

       public void dragGestureRecognized(DragGestureEvent ee) {
     
        ee.startDrag(DragSource.DefaultMoveDrop,Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this),new DragSourceListener(){

         public void dragDropEnd(DragSourceDropEvent dragsourcedropevent) {
          System.out.println("vvdragDropEnd");
         }

         public void dragEnter(DragSourceDragEvent dragsourcedragevent) {
          System.out.println("vvdragEnter");
         }

         public void dragExit(DragSourceEvent dragsourceevent) {
          System.out.println("vvdragExit");
         }

         public void dragOver(DragSourceDragEvent dragsourcedragevent) {
          System.out.println("vvdragOver");
         }

         public void dropActionChanged(DragSourceDragEvent dragsourcedragevent) {
          System.out.println("vvdropActionChanged");
         }});
       }});
      ///////////////////////////////////////////

    Button b= new Button("bbbbb");
      new DropTarget(b,new DropTargetListener(){

       public void dragEnter(DropTargetDragEvent droptargetdragevent) {
        System.out.println("bbdragEnter");
       }

       public void dragExit(DropTargetEvent droptargetevent) {
        System.out.println("bbdragExit");
       }

       public void dragOver(DropTargetDragEvent droptargetdragevent) {
        System.out.println("bbdragOver");
        try {
         System.out.println(droptargetdragevent.getTransferable().getTransferData(DataFlavor.stringFlavor));
        } catch (Exception e) {
         e.printStackTrace();
        }
       }

       public void drop(DropTargetDropEvent droptargetdropevent) {
        System.out.println("bbdrop");
       }

       public void dropActionChanged(DropTargetDragEvent droptargetdragevent) {
        System.out.println("bbdropActionChanged");
       }});

  • 相关阅读:
    nginx源码分析——http模块
    linux 信号处理
    文件读写监控(inotify, systemtap)
    rem
    vscode 将本地项目上传到码云
    vue 模拟去哪网
    form 文件上传
    分页
    修改默认select样式
    模拟select下拉框、复选框效果
  • 原文地址:https://www.cnblogs.com/wbjgogogo/p/4359889.html
Copyright © 2020-2023  润新知