コード例 #1
0
  /** Creates and returns the instanceof JTreeTable that will be used. */
  protected JTreeTable createTreeTable(TreeTableModel model) {
    final JTreeTable treeTable = new JTreeTable(model);
    treeTable
        .getTree()
        .getSelectionModel()
        .setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    treeTable.setDefaultRenderer(Object.class, new ComponentsStringRenderer());
    treeTable.getTree().setCellRenderer(new VRMLComponentsCellRenderer());

    /* treeTable.getTree().addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            textArea.select(textArea.getText().indexOf(e.getPath().getLastPathComponent().toString()),e.getPath().getLastPathComponent().toString().length()+textArea.getText().indexOf(e.getPath().getLastPathComponent().toString()));
            //To change body of implemented methods use File | Settings | File Templates.
        }
    });  */

    return treeTable;
  }
コード例 #2
0
  /**
   * Get the currently selected rows.
   *
   * @return an Iterator whose objects are TableRow
   */
  public Iterator getSelectedRows() {
    TreePath[] paths = table.getSelectionPaths();
    if ((paths == null) || (paths.length < 1)) return null;

    HashSet set = new HashSet(2 * paths.length);
    for (int i = 0; i < paths.length; i++) {
      model.addRowsToSetFromPath(table.getTree(), paths[i], set);
    }

    return set.iterator();
  }