当前位置: 首页>>代码示例>>Java>>正文


Java TreeTableModel.getChild方法代码示例

本文整理汇总了Java中org.jdesktop.swingx.treetable.TreeTableModel.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java TreeTableModel.getChild方法的具体用法?Java TreeTableModel.getChild怎么用?Java TreeTableModel.getChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jdesktop.swingx.treetable.TreeTableModel的用法示例。


在下文中一共展示了TreeTableModel.getChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: interactiveScrollPathToVisible

import org.jdesktop.swingx.treetable.TreeTableModel; //导入方法依赖的package包/类
/**
 * issue #296-swingx: expose scrollPathToVisible in JXTreeTable.
 * 
 * Treetable should behave exactly like Tree - so
 * simply passing through to the hierarchical renderer is not quite
 * enough - need to force a scrollTo after expanding. 
 * Not really: all scrolling is piped through scrollRectToVisible, 
 * so that looks like the central place to fix (f.i. delegate to
 * the enclosing treeTable). Related issue #575-swingx.
 * 
 * note: the action is not guarded against overshooting
 *  at the end of the model!
 */
public void interactiveScrollPathToVisible() {
    // PENDING: FileSystemModel throws occasional NPE on getChildCount()
    final TreeTableModel model = new FileSystemModel();
    final JXTreeTable table = new JXTreeTable(model);
    table.setColumnControlVisible(true);
    final JXTree tree = new JXTree(model);
    Action action = new AbstractAction("path visible") {

        @Override
        public void actionPerformed(ActionEvent e) {
            Rectangle visible = table.getVisibleRect();
            int lastRow = table.rowAtPoint(new Point(5, visible.y + visible.height + 100));
            TreePath path = table.getPathForRow(lastRow);
            Object last = path.getLastPathComponent();
             while (model.isLeaf(last) || model.getChildCount(last) == 0) {
                lastRow++;
                path = table.getPathForRow(lastRow);
                last = path.getLastPathComponent();
            }
            // we have a node with children
            int childCount = model.getChildCount(last); 
            Object lastChild = model.getChild(last, childCount - 1); 
            path = path.pathByAddingChild(lastChild);
            table.scrollPathToVisible(path);
            tree.scrollPathToVisible(path);
            
        }
    };
    JXFrame frame = wrapWithScrollingInFrame(table, tree, "compare scrollPathtovisible");
    addAction(frame, action);
    frame.setVisible(true);

}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:47,代码来源:JXTreeTableVisualCheck.java


注:本文中的org.jdesktop.swingx.treetable.TreeTableModel.getChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。