List of usage examples for javax.swing JTree setDragEnabled
@BeanProperty(bound = false, description = "determines whether automatic drag handling is enabled") public void setDragEnabled(boolean b)
From source file:com.haulmont.cuba.desktop.gui.components.DesktopFilterDragAndDropSupport.java
public void initDragAndDrop(Tree tree, ConditionsTree conditions) { JTree dTree = (JTree) DesktopComponentsHelper.unwrap(tree); dTree.setDragEnabled(true); dTree.setDropMode(DropMode.ON_OR_INSERT); dTree.setTransferHandler(new TreeTransferHandler(tree, conditions)); }
From source file:SwingDnDTest.java
public SwingDnDFrame() { setTitle("SwingDnDTest"); JTabbedPane tabbedPane = new JTabbedPane(); JList list = SampleComponents.list(); tabbedPane.addTab("List", list); JTable table = SampleComponents.table(); tabbedPane.addTab("Table", table); JTree tree = SampleComponents.tree(); tabbedPane.addTab("Tree", tree); JFileChooser fileChooser = new JFileChooser(); tabbedPane.addTab("File Chooser", fileChooser); JColorChooser colorChooser = new JColorChooser(); tabbedPane.addTab("Color Chooser", colorChooser); final JTextArea textArea = new JTextArea(4, 40); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setBorder(new TitledBorder(new EtchedBorder(), "Drag text here")); JTextField textField = new JTextField("Drag color here"); textField.setTransferHandler(new TransferHandler("background")); tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { textArea.setText(""); }//from ww w . j a v a 2 s.co m }); tree.setDragEnabled(true); table.setDragEnabled(true); list.setDragEnabled(true); fileChooser.setDragEnabled(true); colorChooser.setDragEnabled(true); textField.setDragEnabled(true); add(tabbedPane, BorderLayout.NORTH); add(scrollPane, BorderLayout.CENTER); add(textField, BorderLayout.SOUTH); pack(); }
From source file:org.apache.jmeter.gui.MainFrame.java
/** * Create and initialize the GUI representation of the test tree. * * @param treeModel/*from ww w . ja va 2 s. com*/ * the test tree model * @param treeListener * the test tree listener * * @return the initialized test tree GUI */ private JTree makeTree(TreeModel treeModel, JMeterTreeListener treeListener) { JTree treevar = new JTree(treeModel) { private static final long serialVersionUID = 240L; @Override public String getToolTipText(MouseEvent event) { TreePath path = this.getPathForLocation(event.getX(), event.getY()); if (path != null) { Object treeNode = path.getLastPathComponent(); if (treeNode instanceof DefaultMutableTreeNode) { Object testElement = ((DefaultMutableTreeNode) treeNode).getUserObject(); if (testElement instanceof TestElement) { String comment = ((TestElement) testElement).getComment(); if (comment != null && comment.length() > 0) { return comment; } } } } return null; } }; treevar.setToolTipText(""); treevar.setCellRenderer(getCellRenderer()); treevar.setRootVisible(false); treevar.setShowsRootHandles(true); treeListener.setJTree(treevar); treevar.addTreeSelectionListener(treeListener); treevar.addMouseListener(treeListener); treevar.addKeyListener(treeListener); // enable drag&drop, install a custom transfer handler treevar.setDragEnabled(true); treevar.setDropMode(DropMode.ON_OR_INSERT); treevar.setTransferHandler(new JMeterTreeTransferHandler()); addQuickComponentHotkeys(treevar); return treevar; }
From source file:org.nuclos.client.ui.collect.searcheditor.SearchEditorController.java
/** * enables drag&drop, copy&paste * @param tree//w w w . ja va 2 s. co m */ private void setupDataTransfer(final JTree tree) { tree.setDragEnabled(true); tree.setTransferHandler(this.transferhandler); }