/** Constructor. * @param defaultAction should double click on a node open its default action? * @param popupAllowed should right-click open popup? */ public TreeView (boolean defaultAction, boolean popupAllowed) { initializeTree (); // activation of drop target if (DragDropUtilities.dragAndDropEnabled) { ExplorerDnDManager.getDefault ().addFutureDropTarget (this); // note: drag target is activated on focus gained } setPopupAllowed (popupAllowed); setDefaultActionAllowed (defaultAction); Dimension dim = null; try { dim = getPreferredSize(); if (dim == null) { dim = new Dimension(MIN_TREEVIEW_WIDTH, MIN_TREEVIEW_HEIGHT); } } catch (NullPointerException npe) { dim = new Dimension(MIN_TREEVIEW_WIDTH, MIN_TREEVIEW_HEIGHT); } if (dim.width < MIN_TREEVIEW_WIDTH) dim.width = MIN_TREEVIEW_WIDTH; if (dim.height < MIN_TREEVIEW_HEIGHT) dim.height = MIN_TREEVIEW_HEIGHT; setPreferredSize(dim); }
/** Constructor. * @param defaultAction should double click on a node open its default action? * @param popupAllowed should right-click open popup? */ public TreeView (boolean defaultAction, boolean popupAllowed) { initializeTree (); // activation of drop target if (DragDropUtilities.dragAndDropEnabled) { ExplorerDnDManager.getDefault ().addFutureDropTarget (this); // note: drag target is activated on focus gained } setPopupAllowed (popupAllowed); setDefaultActionAllowed (defaultAction); Dimension dim = null; try { dim = getPreferredSize(); if (dim == null) { dim = new Dimension(MIN_TREEVIEW_WIDTH, MIN_TREEVIEW_HEIGHT); } } catch (NullPointerException npe) { dim = new Dimension(MIN_TREEVIEW_WIDTH, MIN_TREEVIEW_HEIGHT); } if (dim.width < MIN_TREEVIEW_WIDTH) dim.width = MIN_TREEVIEW_WIDTH; if (dim.height < MIN_TREEVIEW_HEIGHT) dim.height = MIN_TREEVIEW_HEIGHT; setPreferredSize(dim); }
pnlView.add(tv, BorderLayout.CENTER); tv.setBorder(jScrollPane1.getBorder()); tv.setDefaultActionAllowed(false); tv.setPopupAllowed(false); tv.setRootVisible(false);