javax.swing.JTree.setDragEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中javax.swing.JTree.setDragEnabled()方法的一些代码示例,展示了JTree.setDragEnabled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.setDragEnabled()方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:setDragEnabled

JTree.setDragEnabled介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

private JScrollPane getContent() {
  JTree tree = new JTree();
  tree.setDragEnabled(true);
  tree.setDropMode(DropMode.ON_OR_INSERT);
  tree.setTransferHandler(new TreeTransferHandler());

代码示例来源:origin: org.jspresso/jspresso-swing-application

/**
 * Creates a tree.
 * 
 * @return the created tree.
 */
protected JTree createJTree() {
 JTree tree = new JTree();
 tree.setDragEnabled(true);
 return tree;
}

代码示例来源:origin: org.jspresso.framework/jspresso-swing-application

/**
 * Creates a tree.
 *
 * @param viewDescriptor
 *     the component view descriptor.
 * @return the created tree.
 */
protected JTree createJTree(ITreeViewDescriptor viewDescriptor) {
 JTree tree = new JTree();
 tree.setDragEnabled(true);
 return tree;
}

代码示例来源:origin: Vhati/Slipstream-Mod-Manager

public ChecklistTreePanel() {
  super( new BorderLayout() );
  DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( "Root", true );
  treeModel = new DefaultTreeModel( rootNode, true );
  tree = new JTree( treeModel );
  tree.setCellRenderer( new DefaultTreeCellRenderer() );
  tree.setRootVisible( false );
  tree.getSelectionModel().setSelectionMode( TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION );
  checklistManager = new ChecklistTreeManager( tree, true, null );
  JScrollPane scrollPane = new JScrollPane( tree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
  this.add( scrollPane, BorderLayout.CENTER );
  tree.setTransferHandler( new TreeTransferHandler( tree ) );
  tree.setDropMode( DropMode.ON_OR_INSERT );  // Drop between rows, or onto groups.
  tree.setDragEnabled( true );
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf-testrunner-ui

/** Creates a new instance of ResultTree */
ResultTreeView() {
  super();
  defaultTreeCellRenderer = tree.getCellRenderer();
  noIconTreeCellRenderer = createNoIconTreeCellRenderer();
  tree.setCellRenderer(new DelegatingTreeCellRenderer());
  tree.setDragEnabled(false);
  
  initAccessibility();
}

代码示例来源:origin: uk.org.mygrid.taverna.scufl.scufl-ui-components/workflow-input-panel

portTree.setRowHeight(0);
portTree.setCellRenderer(new InputNodeRenderer());
portTree.setDragEnabled(true);
portTree.getSelectionModel().setSelectionMode(
    TreeSelectionModel.SINGLE_TREE_SELECTION);

代码示例来源:origin: org.apache.uima/uimaj-tools

/**
 * Populate.
 *
 * @param analysisEngine the analysis engine
 * @param aeMetaData the ae meta data
 * @param cas the cas
 */
public void populate(AnalysisEngineDescription analysisEngine, AnalysisEngineMetaData aeMetaData,
    CAS cas) {
 tree = generateTreeView(analysisEngine, aeMetaData, cas);
 tree.setDragEnabled(true); // To allow drag to stylemap table.
 tree.setRootVisible(false);
 tree.setShowsRootHandles(true); // Displays node expansion glyphs.
 TreeSelectionModel selectionModel = tree.getSelectionModel();
 selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
 DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
 cellRenderer.setLeafIcon(null);
 cellRenderer.setClosedIcon(null);
 cellRenderer.setOpenIcon(null);
 tree.setCellRenderer(cellRenderer);
 scrollPane.getViewport().add(tree, null);
}

代码示例来源:origin: nroduit/Weasis

tree.setAlignmentX((float) 0.5);
tree.setShowsRootHandles(false);
tree.setDragEnabled(false);

代码示例来源:origin: bcdev/beam

@SuppressWarnings("UnusedDeclaration")
private void installTreeDragAndDrop() {
  filterTree.setDragEnabled(true);
  filterTree.setDropMode(DropMode.INSERT);
  filterTree.setDropTarget(new DropTarget(filterTree, DnDConstants.ACTION_MOVE, new DropTargetAdapter() {
    @Override
    public void dragEnter(DropTargetDragEvent dtde) {
      System.out.println("dragEnter: dtde = " + dtde);
    }
    @Override
    public void dragOver(DropTargetDragEvent dtde) {
      System.out.println("dragOver: dtde = " + dtde);
    }
    @Override
    public void dropActionChanged(DropTargetDragEvent dtde) {
      System.out.println("dropActionChanged: dtde = " + dtde);
    }
    @Override
    public void dragExit(DropTargetEvent dte) {
      System.out.println("dragExit: dte = " + dte);
    }
    @Override
    public void drop(DropTargetDropEvent dtde) {
      System.out.println("drop: dtde = " + dtde);
    }
  }));
}

代码示例来源:origin: org.apache.uima/uimaj-tools

/**
 * Populate.
 *
 * @param analysisEngine the analysis engine
 * @param aeMetaData the ae meta data
 */
public void populate(AnalysisEngine analysisEngine, AnalysisEngineMetaData aeMetaData) {
 tree = generateTreeView(analysisEngine, aeMetaData);
 tree.setDragEnabled(true); // To allow drag to stylemap table.
 tree.setRootVisible(false);
 tree.setShowsRootHandles(true); // Displays node expansion glyphs.
 TreeSelectionModel selectionModel = tree.getSelectionModel();
 selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
 DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
 cellRenderer.setLeafIcon(null);
 cellRenderer.setClosedIcon(null);
 cellRenderer.setOpenIcon(null);
 tree.setCellRenderer(cellRenderer);
 scrollPane.getViewport().add(tree, null);
}

代码示例来源:origin: MegaMek/mekhq

orgTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
orgTree.addTreeSelectionListener(ev -> refreshForceView());
orgTree.setDragEnabled(true);
orgTree.setDropMode(DropMode.ON);
orgTree.setTransferHandler(new TOETransferHandler(getCampaignGui()));

代码示例来源:origin: senbox-org/snap-desktop

@SuppressWarnings("UnusedDeclaration")
private void installTreeDragAndDrop() {
  filterTree.setDragEnabled(true);
  filterTree.setDropMode(DropMode.INSERT);
  filterTree.setDropTarget(new DropTarget(filterTree, DnDConstants.ACTION_MOVE, new DropTargetAdapter() {
    @Override
    public void dragEnter(DropTargetDragEvent dtde) {
      System.out.println("dragEnter: dtde = " + dtde);
    }
    @Override
    public void dragOver(DropTargetDragEvent dtde) {
      System.out.println("dragOver: dtde = " + dtde);
    }
    @Override
    public void dropActionChanged(DropTargetDragEvent dtde) {
      System.out.println("dropActionChanged: dtde = " + dtde);
    }
    @Override
    public void dragExit(DropTargetEvent dte) {
      System.out.println("dragExit: dte = " + dte);
    }
    @Override
    public void drop(DropTargetDropEvent dtde) {
      System.out.println("drop: dtde = " + dtde);
    }
  }));
}

代码示例来源:origin: net.java.dev.jna/platform

private void disableSwingDragSupport(Component comp) {
  if (comp instanceof JTree) {
    ((JTree)comp).setDragEnabled(false);
  }
  else if (comp instanceof JList) {
    ((JList)comp).setDragEnabled(false);
  }
  else if (comp instanceof JTable) {
    ((JTable)comp).setDragEnabled(false);
  }
  else if (comp instanceof JTextComponent) {
    ((JTextComponent)comp).setDragEnabled(false);
  }
  else if (comp instanceof JColorChooser) {
    ((JColorChooser)comp).setDragEnabled(false);
  }
  else if (comp instanceof JFileChooser) {
    ((JFileChooser)comp).setDragEnabled(false);
  }
}

代码示例来源:origin: net.java.dev.jna/jna-platform

private void disableSwingDragSupport(Component comp) {
  if (comp instanceof JTree) {
    ((JTree)comp).setDragEnabled(false);
  }
  else if (comp instanceof JList) {
    ((JList)comp).setDragEnabled(false);
  }
  else if (comp instanceof JTable) {
    ((JTable)comp).setDragEnabled(false);
  }
  else if (comp instanceof JTextComponent) {
    ((JTextComponent)comp).setDragEnabled(false);
  }
  else if (comp instanceof JColorChooser) {
    ((JColorChooser)comp).setDragEnabled(false);
  }
  else if (comp instanceof JFileChooser) {
    ((JFileChooser)comp).setDragEnabled(false);
  }
}

代码示例来源:origin: jawi/ols

this.tree.setEditable( true );
this.tree.setDragEnabled( true );
this.tree.setDropMode( DropMode.INSERT );
this.tree.setTransferHandler( new JLxTreeTransferHandler() );

代码示例来源:origin: net.sourceforge.jadex/jadex-runtimetools-swing

ftp.getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
ftp.getTree().setDragEnabled(true);
ftp.getTree().setDropMode(DropMode.ON);
ftp.getTree().setTransferHandler(new TreeTransferHandler());

代码示例来源:origin: org.activecomponents.jadex/jadex-runtimetools-swing

ftp.getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
ftp.getTree().setDragEnabled(true);
ftp.getTree().setDropMode(DropMode.ON);
ftp.getTree().setTransferHandler(new TreeTransferHandler());

代码示例来源:origin: org.orbisgis/toc

/**
 * Create the Toc JTree
 *
 * @return the Toc JTree
 */
private JTree makeTree() {
    tree = new JTree();
    //Items can be selected freely
    tree.getSelectionModel().setSelectionMode(
        TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    TocTransferHandler handler = new TocTransferHandler(this);
    //Add a drop listener
    handler.getTransferEditableEvent().addListener(this,
        EventHandler.create(EditableTransferListener.class, this, "onDropEditableElement", ""));
    tree.setDragEnabled(true);
    tree.setTransferHandler(handler);
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    tree.setEditable(true);
    treeRenderer = new TocRenderer(tree);
    tree.setCellRenderer(treeRenderer);
    setEmptyLayerModel(tree);
    tree.setCellEditor(new TocTreeEditor(tree));
    tree.addMouseListener(new PopupMouselistener());
    //Add a tree selection listener
    tree.getSelectionModel().addTreeSelectionListener(
        EventHandler.create(TreeSelectionListener.class, this, "onTreeSelectionChange"));
    return tree;
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_core

treevar.setDragEnabled(true);
treevar.setDropMode(DropMode.ON_OR_INSERT);
treevar.setTransferHandler(new JMeterTreeTransferHandler());

代码示例来源:origin: org.xworker/xworker_core

comp.setDragEnabled(dragEnabled);

相关文章

JTree类方法