本文整理汇总了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);
}