亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? dndjtree.java

?? 鼠標拖拽的例子
?? JAVA
字號:
/***  This is version II of DnDJTree. The first version allowed for what I **  thought was a JDK oversight. However, we can set the cursor appropriately,**  relative to whether the current cursor location is a valid drop target.****  If this is your first time reading the source code. Just ignore the above**  comment and ignore the "CHANGED" comments below. Otherwise, the **  "CHANGED" comments will show where the code has changed.****  Credit for finding this shortcoming in my code goes Laurent Hubert.**  Thanks Laurent.****  Rob. [ rkenworthy@hotmail.com ]*/import javax.swing.*;import javax.swing.event.*;import javax.swing.plaf.metal.*;import javax.swing.tree.*;import java.awt.*;import java.awt.datatransfer.*;import java.awt.dnd.*;import java.awt.dnd.peer.*;import java.awt.event.*;import java.io.*;public class DnDJTree extends JTree                  implements TreeSelectionListener,                   DragGestureListener, DropTargetListener,                  DragSourceListener {  /** Stores the parent Frame of the component */  private Frame Parent = null;  /** Stores the selected node info */  protected TreePath SelectedTreePath = null;  protected PersonNode SelectedNode = null;  /** Variables needed for DnD */  private DragSource dragSource = null;  private DragSourceContext dragSourceContext = null;  /** Constructor   @param root The root node of the tree  @param parent Parent JFrame of the JTree */  public DnDJTree(PersonNode root, Frame parent) {    super(root);    Parent = parent;    addTreeSelectionListener(this);		/* ********************** CHANGED ********************** */    dragSource = DragSource.getDefaultDragSource() ;		/* ****************** END OF CHANGE ******************** */        DragGestureRecognizer dgr =       dragSource.createDefaultDragGestureRecognizer(        this,                             //DragSource        DnDConstants.ACTION_COPY_OR_MOVE, //specifies valid actions        this                              //DragGestureListener      );    /* Eliminates right mouse clicks as valid actions - useful especially     * if you implement a JPopupMenu for the JTree     */    dgr.setSourceActions(dgr.getSourceActions() & ~InputEvent.BUTTON3_MASK);    /* First argument:  Component to associate the target with     * Second argument: DropTargetListener     */    DropTarget dropTarget = new DropTarget(this, this);    //unnecessary, but gives FileManager look    putClientProperty("JTree.lineStyle", "Angled");    MetalTreeUI ui = (MetalTreeUI) getUI();  }  /** Returns The selected node */  public PersonNode getSelectedNode() {    return SelectedNode;  }  ///////////////////////// Interface stuff ////////////////////  /** DragGestureListener interface method */  public void dragGestureRecognized(DragGestureEvent e) {    //Get the selected node    PersonNode dragNode = getSelectedNode();    if (dragNode != null) {      //Get the Transferable Object      Transferable transferable = (Transferable) dragNode.getUserObject();			/* ********************** CHANGED ********************** */      //Select the appropriate cursor;      Cursor cursor = DragSource.DefaultCopyNoDrop;      int action = e.getDragAction();      if (action == DnDConstants.ACTION_MOVE)         cursor = DragSource.DefaultMoveNoDrop;                      //In fact the cursor is set to NoDrop because once an action is rejected      // by a dropTarget, the dragSourceListener are no more invoked.      // Setting the cursor to no drop by default is so more logical, because       // when the drop is accepted by a component, then the cursor is changed by the      // dropActionChanged of the default DragSource.			/* ****************** END OF CHANGE ******************** */         //begin the drag      dragSource.startDrag(e, cursor, transferable, this);    }  }  /** DragSourceListener interface method */  public void dragDropEnd(DragSourceDropEvent dsde) {  }  /** DragSourceListener interface method */  public void dragEnter(DragSourceDragEvent dsde) {		/* ********************** CHANGED ********************** */		/* ****************** END OF CHANGE ******************** */  }  /** DragSourceListener interface method */  public void dragOver(DragSourceDragEvent dsde) {		/* ********************** CHANGED ********************** */		/* ****************** END OF CHANGE ******************** */  }  /** DragSourceListener interface method */  public void dropActionChanged(DragSourceDragEvent dsde) {  }  /** DragSourceListener interface method */  public void dragExit(DragSourceEvent dsde) {  }        /** DropTargetListener interface method - What we do when drag is released */  public void drop(DropTargetDropEvent e) {    try {      Transferable tr = e.getTransferable();      //flavor not supported, reject drop      if (!tr.isDataFlavorSupported( PersonalInfo.INFO_FLAVOR)) e.rejectDrop();      //cast into appropriate data type      PersonalInfo childInfo =         (PersonalInfo) tr.getTransferData( PersonalInfo.INFO_FLAVOR );      //get new parent node      Point loc = e.getLocation();      TreePath destinationPath = getPathForLocation(loc.x, loc.y);      final String msg = testDropTarget(destinationPath, SelectedTreePath);      if (msg != null) {        e.rejectDrop();        SwingUtilities.invokeLater(new Runnable() {          public void run() {            JOptionPane.showMessageDialog(                 Parent, msg, "Error Dialog", JOptionPane.ERROR_MESSAGE            );          }        });        return;      }      PersonNode newParent =        (PersonNode) destinationPath.getLastPathComponent();      //get old parent node      PersonNode oldParent = (PersonNode) getSelectedNode().getParent();      int action = e.getDropAction();      boolean copyAction = (action == DnDConstants.ACTION_COPY);      //make new child node      PersonNode newChild = new PersonNode(childInfo);      try {         if (!copyAction) oldParent.remove(getSelectedNode());        newParent.add(newChild);                  if (copyAction) e.acceptDrop (DnDConstants.ACTION_COPY);        else e.acceptDrop (DnDConstants.ACTION_MOVE);      }      catch (java.lang.IllegalStateException ils) {        e.rejectDrop();      }      e.getDropTargetContext().dropComplete(true);      //expand nodes appropriately - this probably isnt the best way...      DefaultTreeModel model = (DefaultTreeModel) getModel();      model.reload(oldParent);      model.reload(newParent);      TreePath parentPath = new TreePath(newParent.getPath());      expandPath(parentPath);    }    catch (IOException io) { e.rejectDrop(); }    catch (UnsupportedFlavorException ufe) {e.rejectDrop();}  } //end of method  /** DropTaregetListener interface method */  public void dragEnter(DropTargetDragEvent e) {  }  /** DropTaregetListener interface method */  public void dragExit(DropTargetEvent e) {   }  /** DropTaregetListener interface method */  public void dragOver(DropTargetDragEvent e) {		/* ********************** CHANGED ********************** */    //set cursor location. Needed in setCursor method    Point cursorLocationBis = e.getLocation();        TreePath destinationPath =       getPathForLocation(cursorLocationBis.x, cursorLocationBis.y);    // if destination path is okay accept drop...    if (testDropTarget(destinationPath, SelectedTreePath) == null){    	e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE ) ;    }    // ...otherwise reject drop    else {    	e.rejectDrag() ;    }		/* ****************** END OF CHANGE ******************** */  }  /** DropTaregetListener interface method */  public void dropActionChanged(DropTargetDragEvent e) {  }  /** TreeSelectionListener - sets selected node */  public void valueChanged(TreeSelectionEvent evt) {    SelectedTreePath = evt.getNewLeadSelectionPath();    if (SelectedTreePath == null) {      SelectedNode = null;      return;    }    SelectedNode =       (PersonNode)SelectedTreePath.getLastPathComponent();  }  /** Convenience method to test whether drop location is valid  @param destination The destination path   @param dropper The path for the node to be dropped  @return null if no problems, otherwise an explanation  */  private String testDropTarget(TreePath destination, TreePath dropper) {    //Typical Tests for dropping     //Test 1.    boolean destinationPathIsNull = destination == null;    if (destinationPathIsNull)       return "Invalid drop location.";    //Test 2.    PersonNode node = (PersonNode) destination.getLastPathComponent();    if ( !node.getAllowsChildren() )      return "This node does not allow children";    if (destination.equals(dropper))      return "Destination cannot be same as source";    //Test 3.    if ( dropper.isDescendant(destination))        return "Destination node cannot be a descendant.";    //Test 4.    if ( dropper.getParentPath().equals(destination))        return "Destination node cannot be a parent.";    return null;  }  //program entry point  public static final void main(String args[]) {    JFrame f = new JFrame();    Container c = f.getContentPane();    //Generate your family "tree"    PersonalInfo pi =       new PersonalInfo("GrandMother", PersonalInfo.FEMALE);    PersonNode grandmother =       new PersonNode(pi);    pi = new PersonalInfo("Mother", PersonalInfo.FEMALE);    PersonNode mother = new PersonNode(pi);    pi = new PersonalInfo("Daughter", PersonalInfo.FEMALE);    PersonNode daughter = new PersonNode(pi);    pi = new PersonalInfo("Baby", PersonalInfo.FEMALE);    PersonNode baby = new PersonNode(pi);    pi = new PersonalInfo("Son", PersonalInfo.MALE);    PersonNode son = new PersonNode(pi);    grandmother.add(mother);    mother.add(daughter);    mother.add(son);    daughter.add(baby);    //add the tree to the frame and display the frame.    c.add(new DnDJTree(grandmother, f));    f.pack();    f.show();  }} //end of DnDJTree

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美私人免费视频| 国内一区二区在线| 亚洲天堂免费在线观看视频| 国产日韩欧美精品电影三级在线| 日韩一区二区免费在线电影| 欧美一区二区免费| 精品三级在线看| 久久亚洲一级片| 国产欧美精品一区| 中文字幕亚洲区| 亚洲男人的天堂在线观看| 亚洲私人黄色宅男| 亚洲国产精品一区二区久久| 亚洲成人免费在线观看| 日韩二区三区在线观看| 老司机免费视频一区二区| 国内成人自拍视频| 成人黄色一级视频| 欧美午夜精品久久久久久孕妇| 91成人看片片| 日韩一级二级三级精品视频| 精品美女在线播放| 国产精品你懂的在线欣赏| 中文字幕日韩欧美一区二区三区| 亚洲一区二区三区小说| 麻豆国产欧美日韩综合精品二区| 国产成人午夜高潮毛片| 91蜜桃在线观看| 欧美一区二区三区四区五区| 国产欧美日韩在线观看| 亚洲女人的天堂| 麻豆视频一区二区| 91最新地址在线播放| 制服丝袜成人动漫| 中文字幕乱码日本亚洲一区二区| 一区二区三区中文在线| 蜜桃视频第一区免费观看| 不卡av在线免费观看| 91精品国产入口| 亚洲视频免费在线| 狠狠色狠狠色综合系列| 色婷婷久久99综合精品jk白丝| 91精品国产综合久久精品图片| 中文乱码免费一区二区| 奇米影视在线99精品| 99在线精品免费| 久久天堂av综合合色蜜桃网| 亚洲图片欧美色图| av影院午夜一区| 欧美精品一区二区高清在线观看| 一区二区久久久久久| 夫妻av一区二区| 日韩免费电影网站| 日韩中文字幕区一区有砖一区 | 国产精品1区2区3区| 欧美色偷偷大香| 综合亚洲深深色噜噜狠狠网站| 久久成人羞羞网站| 欧美精品九九99久久| 一区二区三区中文字幕电影 | 午夜视频一区二区三区| 成人av在线观| 中文一区二区完整视频在线观看| 男人的j进女人的j一区| 欧美三级中文字| 亚洲最大成人综合| 97久久久精品综合88久久| 亚洲国产成人自拍| 成人一级视频在线观看| 国产亚洲综合在线| 国产伦精品一区二区三区免费迷 | 欧美中文字幕一二三区视频| 国产精品蜜臀在线观看| 成人午夜私人影院| 中文字幕免费观看一区| 北条麻妃国产九九精品视频| 国产精品久久久久久久午夜片| 国产精品资源网站| 欧美激情一区二区三区全黄| 成人性生交大合| 国产精品久久国产精麻豆99网站| 不卡的看片网站| 亚洲精品久久7777| 欧美色视频在线观看| 亚洲一区二区美女| 欧美一区二区三区在线观看 | 亚洲欧洲精品天堂一级| jiyouzz国产精品久久| 亚洲欧美综合另类在线卡通| 一本久久综合亚洲鲁鲁五月天| 亚洲嫩草精品久久| 欧美一卡2卡三卡4卡5免费| 久久99精品久久久| 欧美激情综合在线| 色婷婷久久99综合精品jk白丝| 亚洲尤物在线视频观看| 5月丁香婷婷综合| 国产乱淫av一区二区三区 | 成人av网址在线| 亚洲精选视频在线| 91精品国产色综合久久ai换脸| 国内精品国产三级国产a久久| 欧美国产日韩一二三区| 欧美无砖专区一中文字| 国内精品不卡在线| 亚洲免费av在线| 日韩欧美123| 91一区二区三区在线观看| 日韩和欧美一区二区| 国产视频一区不卡| 欧美三级日韩在线| 盗摄精品av一区二区三区| 一区二区三区中文免费| 日韩免费观看高清完整版在线观看| 国产激情一区二区三区| 午夜久久久影院| 国产精品第五页| 3d动漫精品啪啪一区二区竹菊| 国产成人h网站| 麻豆免费精品视频| 亚洲一级二级三级在线免费观看| 久久九九国产精品| 欧美一级黄色大片| 日本高清不卡aⅴ免费网站| 国产综合色在线| 天堂在线一区二区| 亚洲日本va午夜在线影院| 久久综合久久鬼色中文字| 欧美色倩网站大全免费| 成人av电影在线播放| 国产真实精品久久二三区| 亚洲国产日日夜夜| 亚洲天堂成人在线观看| 久久久久久综合| 欧美大片在线观看一区| 欧美日韩国产一区| 一本到高清视频免费精品| 国产aⅴ综合色| 国产99久久久国产精品潘金| 日韩电影在线观看一区| 亚洲一区二区不卡免费| 亚洲欧美日韩一区二区三区在线观看 | 精品视频在线免费看| av网站一区二区三区| 国产成人免费高清| 国产精品自在欧美一区| 激情图区综合网| 激情成人午夜视频| 国内一区二区在线| 黄色精品一二区| 国产毛片精品一区| 成人综合婷婷国产精品久久| 国产一区二区福利| 成人性色生活片免费看爆迷你毛片| 国产一区美女在线| 国产成人精品aa毛片| 懂色av一区二区在线播放| 国产大陆亚洲精品国产| 国产黄色精品网站| 成人丝袜18视频在线观看| 成人免费高清在线| 91麻豆国产自产在线观看| 色乱码一区二区三区88| 欧美日韩国产一级二级| 欧美一卡二卡在线观看| 久久久精品欧美丰满| 国产欧美日韩精品在线| 亚洲女人小视频在线观看| 亚洲成a人v欧美综合天堂 | 国产一区二三区好的| 国产一区美女在线| 99视频有精品| 欧美少妇性性性| 精品免费一区二区三区| 国产精品免费丝袜| 亚洲动漫第一页| 精品一二三四区| 色综合久久综合中文综合网| 欧美日韩第一区日日骚| 久久综合网色—综合色88| 国产精品色在线观看| 亚洲综合成人在线视频| 免费高清在线视频一区·| 国产91精品欧美| 欧美三级中文字幕在线观看| 精品美女在线观看| 樱桃视频在线观看一区| 久久av资源站| 色综合久久88色综合天天| 日韩欧美国产电影| 性做久久久久久久免费看| 久久99日本精品| 色偷偷久久人人79超碰人人澡| 欧美一级黄色大片| 亚洲蜜桃精久久久久久久| 精品一区二区三区免费毛片爱| 91色在线porny| 久久亚洲二区三区| 午夜精品视频一区| 成人高清视频在线观看|