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

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

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

JTree.setSelectionModel介绍

暂无

代码示例

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

this.setSelectionModel(dtsm);

代码示例来源:origin: de.sciss/jtreetable

protected void unconfigureTree() {
  tree.setCellRenderer(null);
  tree.setModel(new DefaultTreeModel(null));
  tree.setSelectionModel(new DefaultTreeSelectionModel());
  tree.setUI(null);
}

代码示例来源:origin: net.sf.jt400/jt400

/**
Sets the selection model that is used to maintain selection
state.  This provides the ability to programmatically select
and deselect objects.

@param  selectionModel  The selection model, or null if selections
            are not allowed.
**/
  public void setSelectionModel (TreeSelectionModel selectionModel)
  {
    // Do not dispatch events from the old selection model any more.
    TreeSelectionModel oldSelectionModel = tree_.getSelectionModel ();
    if (oldSelectionModel != null)
      oldSelectionModel.removeTreeSelectionListener (treeSelectionEventSupport_);

    tree_.setSelectionModel (selectionModel);

    // Dispatch events from the new selection model.
    if (selectionModel != null)
      selectionModel.addTreeSelectionListener (treeSelectionEventSupport_);
  }

代码示例来源:origin: org.fudaa.framework.ebli/ebli-2d

/**
 * Creation d'une vue pour le modele.
 */
public JTree createView(final boolean _onlyGeomSelected, final boolean _multiSelection) {
 final JTree tree = new JTree(this);
 tree.setEditable(false);
 tree.setShowsRootHandles(true);
 tree.setExpandsSelectedPaths(true);
 tree.setCellRenderer(new CellRenderer(_onlyGeomSelected));
 tree.setRootVisible(false);
 tree.setFocusable(true);
 if (_onlyGeomSelected) {
  final TreeSelectionModel onlyGeomSelectionModel = new OnlyGeomTreeSelectionModel();
  tree.setSelectionModel(onlyGeomSelectionModel);
 }
 
 if (_multiSelection)
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
 else 
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
 return tree;
}

代码示例来源:origin: pentaho/pentaho-reporting

/**
 * Creates the JTree for the report configuration.
 *
 * @return the tree component.
 * @throws ConfigTreeModelException if the model could not be built.
 */
private JComponent createEntryTree( final boolean includeGlobals ) {
 treeModel = new ConfigTreeModel( packageManager, includeGlobals );
 final TreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
 selectionModel.setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
 tree = new JTree( treeModel );
 tree.setSelectionModel( selectionModel );
 tree.setCellRenderer( new ConfigTreeRenderer() );
 tree.setRootVisible( false );
 tree.setShowsRootHandles( true );
 tree.addTreeSelectionListener( new ModuleTreeSelectionHandler() );
 return new JScrollPane
  ( tree, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
   ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER );
}

代码示例来源:origin: net.sf.gluebooster.java.booster/gb-basic

public void setBean(Object bean) throws Exception {
  this.bean = bean;
  DefaultMutableTreeNode rootNode = new BeanTreeNode(bean);
  model = new DefaultTreeModel(rootNode);
  tree = new JTree(model);
  tree.setEditable(true);
  DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
  selectionModel
      .setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.setSelectionModel(selectionModel);
  tree.addTreeSelectionListener(this);
  // put the tree into the old scroll pane, if it exists
  boolean found = false;
  for (Component component : getComponents()) {
    if (component instanceof JScrollPane) {
      found = true;
      JScrollPane pane = (JScrollPane) component;
      pane.setViewportView(tree);
    }
  }
  if (!found)
    add(new JScrollPane(tree), BorderLayout.CENTER);
  // model.addTreeModelListener(this);
}

代码示例来源:origin: fr.ifremer/isis-fish

fisheryRegionTreeSelectionModel.setSelectionMode(javax.swing.tree.TreeSelectionModel.SINGLE_TREE_SELECTION);
fisheryRegionTree.setModel(new javax.swing.tree.DefaultTreeModel(null));
fisheryRegionTree.setSelectionModel(fisheryRegionTreeSelectionModel);
inputPanePrincipal.setMinimumSize(new java.awt.Dimension(0,0));

代码示例来源:origin: net.sf.squirrel-sql.plugins/firebirdmanager

private void createTargetTree()
{
  rootNode = new FirebirdManagerGrantTreeNode(i18n.GRANTMANAGER_LBL_TREENODE_ROOT, TREENODE_TYPE_ROOT);
  DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
  jtreeReceiver = new JTree(treeModel);
  jtreeReceiver.addTreeSelectionListener(new TreeSelectionListener()
  {
    public void valueChanged(TreeSelectionEvent e)
    {
      FirebirdManagerGrantTreeNode node =
        (FirebirdManagerGrantTreeNode) e.getPath().getLastPathComponent();
      gsTreenodeName = node.getUserObject().toString();
      gTreenodeType = node.getTreenodeType();
      readData();
    }
  });
  TreeSelectionModel tsm = new DefaultTreeSelectionModel();
  tsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  jtreeReceiver.setBackground(Color.LIGHT_GRAY);
  jtreeReceiver.setSelectionModel(tsm);
  jtreeReceiver.setEnabled(true);
  jtreeReceiver.setRootVisible(true); // false);
  FirebirdManagerGrantTreeRenderer treeRenderer = new FirebirdManagerGrantTreeRenderer();
  jtreeReceiver.setCellRenderer(treeRenderer);
  setTreeData();
}

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

public static void createSelectionModel(ActionContext actionContext){
  Thing self = (Thing) actionContext.get("self");
  JTree parent = (JTree) actionContext.get("parent");
  
  for(Thing child : self.getChilds()){
    TreeSelectionModel obj = (TreeSelectionModel) child.doAction("create", actionContext);
    if(obj != null){
      parent.setSelectionModel(obj);
      break;
    }
  }
}

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

TreeSelectionModel treeSelectionModel = new DefaultTreeSelectionModel();
treeSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
this.typeTree.setSelectionModel(treeSelectionModel);
JScrollPane treePane = new JScrollPane(this.typeTree);
contentPane.setLeftComponent(treePane);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-designer

public void refresh() {
  PageBox pageBox = webform.getPane().getPageBox();
  TreeNode root = new BoxTreeNode(pageBox, null);
  treeModel = new DefaultTreeModel(root);
  treeSelectionModel = new DefaultTreeSelectionModel();
  treeSelectionModel.addTreeSelectionListener(this);
  tree.setSelectionModel(treeSelectionModel);
  tree.setModel(treeModel);
}

代码示例来源:origin: org.fudaa.framework.ebli/ebli-2d

public static JTree createCalqueTree(final CalqueFindCourbeTreeModel _treeModel, final boolean _onlyCourbeSelected) {
 final JTree tree = new JTree(_treeModel.getTreeModel());
 tree.setEditable(false);
 tree.setShowsRootHandles(true);
 tree.setExpandsSelectedPaths(true);
 tree.setCellRenderer(createRenderer(_onlyCourbeSelected));
 tree.setRootVisible(false);
 tree.setFocusable(true);
 if (_onlyCourbeSelected) {
  final TreeSelectionModel onlyCourbeSelectionModel = getOnlyCourbeSelectionModel();
  onlyCourbeSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.setSelectionModel(onlyCourbeSelectionModel);
 }
 return tree;
}

代码示例来源:origin: fr.ifremer/isis-fish

fisheryRegionTree.setSelectionModel(getFisheryRegionTreeSelectionModel());
$JButton0.setIcon(SwingUtil.createImageIcon("factors/dgroup.png"));
$JButton1.setIcon(SwingUtil.createImageIcon("factors/cgroup.png"));

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

treeTable.setCellSelectionEnabled(false);
treeTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
treeTable.getTree().setSelectionModel(new DefaultTreeSelectionModel());

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-propertyeditors

tree.setSelectionModel(treeSelectionModel);
treeSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
treeSelectionModel.addTreeSelectionListener(new TreeSelectionListener() {

代码示例来源:origin: edu.stanford.protege/jtreetable

tree.setSelectionModel(selectionWrapper);
table.setSelectionModel(selectionWrapper.getListSelectionModel());
selectionWrapper.addTreeSelectionListener(new TreeSelectionListener(){

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-jsfsupport-designtime

tree.setSelectionModel(treeSelectionModel);
treeSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
treeSelectionModel.addTreeSelectionListener(new TreeSelectionListener() {

代码示例来源:origin: link-intersystems/blog

personTable.setSelectionModel(selectionModel);
personComboBoxModel.setListSelectionModel(selectionModel);
personTree.setSelectionModel(treeSelectionListModelSelectionAdapter);

代码示例来源:origin: org.fudaa.framework.ebli/ebli-2d

/**
 * Met a jour le modele et la selection.
 * 
 * @param _m le nouveau modele
 */
public final void setModel(final BArbreCalqueModel _m) {
 if (getModel()!=null)
  ((BArbreCalqueModel)getModel()).getObservable().deleteObserver(this);
 if (_m!=null)
  _m.getObservable().addObserver(this);
 
 // pour eviter d'initialiser l'ancien model de selection
 super.setSelectionModel(null);
 super.setModel(_m);
 if (_m != null) {
  final TreePath p = _m.getTreeSelectionModel().getSelectionPath();
  super.setSelectionModel(_m.getTreeSelectionModel());
  if (p != null) {
   final TreePath par = p.getParentPath();
   if (par != null) {
    expandPath(par);
   }
  }
 }
}

代码示例来源:origin: de.sciss/jtreetable

protected JTree createAndConfigureTree() {
  JTree tree = createTree(treeTable.getTreeTableModel());
  if (treeTable.getSelectionModel() == null) {
    treeTable.setSelectionModel(tree.getSelectionModel());
  } else {
    tree.setSelectionModel(treeTable.getSelectionModel());
  }
  tree.setOpaque(false);
  tree.setRowHeight(20);
  tree.putClientProperty("JTree.lineStyle", "None");
  InputMap inputs = tree.getInputMap();
  remap(inputs, KeyEvent.VK_LEFT);
  remap(inputs, KeyEvent.VK_RIGHT);
  updateTreeClientProperties(tree);
  return tree;
}

相关文章

JTree类方法