本文整理汇总了Java中javax.swing.JTree.getRowCount方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.getRowCount方法的具体用法?Java JTree.getRowCount怎么用?Java JTree.getRowCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTree
的用法示例。
在下文中一共展示了JTree.getRowCount方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveExpansionState
import javax.swing.JTree; //导入方法依赖的package包/类
/**
* Saves the currently selected paths and saves all expanded repositories and nodes.
*
* @param tree
* The related tree, containing the path(s)
*/
public void saveExpansionState(JTree tree) {
saveSelectionPaths(tree.getSelectionPaths());
expandedNodes = new HashSet<>();
expandedRepositories = new HashSet<>();
for (int i = 0; i < tree.getRowCount(); i++) {
TreePath path = tree.getPathForRow(i);
if (tree.isExpanded(path)) {
Entry entry = (Entry) path.getLastPathComponent();
String absoluteLocation = entry.getLocation().getAbsoluteLocation();
if (entry instanceof Repository) {
expandedRepositories.add(absoluteLocation);
} else {
expandedNodes.add(absoluteLocation);
}
}
}
}
示例2: restoreExpansionState
import javax.swing.JTree; //导入方法依赖的package包/类
/**
* Expands all repositories and nodes, which have been saved before. Restores selected paths,
* which have been saved proviously.
*
* @param tree
* The related tree, containing the path(s)
*/
public void restoreExpansionState(JTree tree) {
for (int i = 0; i < tree.getRowCount(); i++) {
TreePath path = tree.getPathForRow(i);
Object entryObject = path.getLastPathComponent();
if (entryObject instanceof Entry) {
Entry entry = (Entry) entryObject;
String absoluteLocation = entry.getLocation().getAbsoluteLocation();
if (expandedRepositories.contains(absoluteLocation) || expandedNodes.contains(absoluteLocation)) {
tree.expandPath(path);
}
}
}
restoreSelectionPaths(tree);
}
示例3: manipulateJTree
import javax.swing.JTree; //导入方法依赖的package包/类
/**
* This method aids in the creation of the JTrees which are used to add in
* the JTabbedPane component
*
* @param top
* - input to the JTree which will be formatted for display
* @return JTree which will be used for adding to the root of a pane
*/
private JTree manipulateJTree(final DefaultMutableTreeNode top) {
final JTree resultsTree = new JTree(top) {
private static final long serialVersionUID = 1748421292182815368L;
@Override
public Insets getInsets() {
return new Insets(5, 5, 5, 5);
}
};
resultsTree.setRootVisible(false);
resultsTree.setShowsRootHandles(true);
if (resultsTree.getRowCount() > 0) {
resultsTree.expandRow(0);
}
return resultsTree;
}
示例4: restoreLastExpandedPaths
import javax.swing.JTree; //导入方法依赖的package包/类
/**
* Expand all the path from the given expandedPaths and the given tree
*
* @param expandedPaths
* - the paths to expand
* @param tree
* - the tree on which the paths has to be expanded
*/
public static void restoreLastExpandedPaths(Enumeration<TreePath> expandedPaths, JTree tree) {
if (expandedPaths != null) {
List<TreePath> paths = Collections.list(expandedPaths);
for (int i = 0; i < tree.getRowCount(); i++) {
TreePath currentPath = tree.getPathForRow(i);
String currentStringPath = TreeFormatter.getStringPath(currentPath);
for (TreePath treePath : paths) {
String stringTreePahr = TreeFormatter.getStringPath(treePath);
if (currentStringPath.equals(stringTreePahr)) {
tree.expandRow(i);
}
}
}
}
}
示例5: selectNextPrev
import javax.swing.JTree; //导入方法依赖的package包/类
static void selectNextPrev(final boolean next, boolean isQuery, JTree tree) {
int[] rows = tree.getSelectionRows();
int newRow = rows == null || rows.length == 0 ? 0 : rows[0];
int maxcount = tree.getRowCount();
CheckNode node;
do {
if (next) {
newRow++;
if (newRow >= maxcount) {
newRow = 0;
}
} else {
newRow--;
if (newRow < 0) {
newRow = maxcount - 1;
}
}
TreePath path = tree.getPathForRow(newRow);
node = (CheckNode) path.getLastPathComponent();
if (!node.isLeaf()) {
tree.expandRow(newRow);
maxcount = tree.getRowCount();
}
} while (!node.isLeaf());
tree.setSelectionRow(newRow);
tree.scrollRowToVisible(newRow);
if (isQuery) {
CheckNodeListener.findInSource(node);
} else {
CheckNodeListener.openDiff(node);
}
}
示例6: selectNextPrev
import javax.swing.JTree; //导入方法依赖的package包/类
static void selectNextPrev(final boolean next, boolean isQuery, JTree tree) {
int[] rows = tree.getSelectionRows();
int newRow = rows == null || rows.length == 0 ? 0 : rows[0];
int maxcount = tree.getRowCount();
CheckNode node;
do {
if (next) {
newRow++;
if (newRow >= maxcount) {
newRow = 0;
}
} else {
newRow--;
if (newRow < 0) {
newRow = maxcount - 1;
}
}
TreePath path = tree.getPathForRow(newRow);
node = (CheckNode) path.getLastPathComponent();
if (!node.isLeaf()) {
tree.expandRow(newRow);
maxcount = tree.getRowCount();
}
} while (!node.isLeaf());
tree.setSelectionRow(newRow);
tree.scrollRowToVisible(newRow);
}
示例7: getJTree
import javax.swing.JTree; //导入方法依赖的package包/类
private JTree getJTree() {
DebugTreeView treeView1 = getTreeView();
if (treeView1 != null) {
JTree tree = treeView1.getTree();
if (tree != null && tree.getRowCount() > 0) {
return tree;
}
}
return null;
}
示例8: getExpandedPaths
import javax.swing.JTree; //导入方法依赖的package包/类
public static ArrayList<String> getExpandedPaths(JTree tree) {
ArrayList<String> paths_expanded = new ArrayList<>();
for(int i = 0; i < tree.getRowCount(); i++) {
TreePath tp = tree.getPathForRow(i);
if(tree.isExpanded(i)) {
paths_expanded.add(tp.toString());
}
}
return paths_expanded;
}
示例9: expandPaths
import javax.swing.JTree; //导入方法依赖的package包/类
public static void expandPaths(JTree tree, ArrayList<String> paths_expanded) {
for(int i = 0; i < tree.getRowCount(); i++) {
TreePath tp = tree.getPathForRow(i);
if(paths_expanded.contains(tp.toString())) {
tree.expandRow(i);
}
}
}
示例10: expandAllNodes
import javax.swing.JTree; //导入方法依赖的package包/类
private void expandAllNodes(JTree tree, int startingIndex, int rowCount){
for (int i=startingIndex;i<rowCount;++i)
tree.expandRow(i);
if (tree.getRowCount()!=rowCount)
expandAllNodes(tree, rowCount, tree.getRowCount());
}
示例11: expandAllNodes
import javax.swing.JTree; //导入方法依赖的package包/类
private void expandAllNodes(JTree tree, int startingIndex, int rowCount) {
for (int i = startingIndex; i < rowCount; ++i) {
tree.expandRow(i);
}
if (tree.getRowCount() != rowCount) {
expandAllNodes(tree, rowCount, tree.getRowCount());
}
}
示例12: createTreePane
import javax.swing.JTree; //导入方法依赖的package包/类
public JScrollPane createTreePane() {
// new tree
root = new DefaultMutableTreeNode("Root");
tree = new JTree(root);
tree.setEditable(false);
// click tree
tree.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
if (selPath != null) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent();
if (node.isLeaf()) {
String type = (String) node.getUserObject();
String strpar = node.getParent().toString();
String strcur = node.toString();
String selectedObjectParent = strpar;
selectedObject = strpar +"." + strcur;
if (console.wMode == HMLP_Console.windowMode.SELECT_DB){
console.insertTextOut("The database \"" + selectedObject +"\" was selected.");
} else if (console.wMode == HMLP_Console.windowMode.EDIT_DB){
} else if (console.wMode == HMLP_Console.windowMode.ADD_PARENTS){
console.insertTextOut("The node \"" + selectedObject +"\" was selected.");
} else if (console.wMode == windowMode.JOIN_RELATIONS) {
} else if (console.wMode == HMLP_Console.windowMode.ADD_CLD){
console.insertTextOut("The node \"" + selectedObject +"\" was selected.");
} else if (console.wMode == windowMode.LEARNING) {
} else if (console.wMode == windowMode.EVALUATION) {
}
}
}
}
});
// Expand all
for (int i = 0; i < tree.getRowCount(); i++)
tree.expandRow(i);
return new JScrollPane(tree);
}
示例13: createTreePane
import javax.swing.JTree; //导入方法依赖的package包/类
public JScrollPane createTreePane() {
// new tree
root = new DefaultMutableTreeNode("Root");
tree = new JTree(root);
tree.setEditable(false);
// click tree
tree.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
if (selPath != null) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent();
if (node.isLeaf()) {
TreePath[] threePaths = tree.getSelectionPaths();
selectedObjects.clear();
for (TreePath tp: threePaths){
DefaultMutableTreeNode eachNode = (DefaultMutableTreeNode) tp.getLastPathComponent();
String strpar = eachNode.getParent().toString();
String str = strpar + "." + eachNode.toString();
selectedObjects.add(str);
}
// String type = (String) node.getUserObject();
// String str2 = node.toString();
// String strpar = node.getParent().toString();
// selectedObject = str2;
if (console.wMode == HMLP_Console.windowMode.SELECT_DB){
console.insertTextOut("The database \"" + selectedObjects +"\" was selected.");
} else if (console.wMode == HMLP_Console.windowMode.EDIT_DB){
} else if (console.wMode == HMLP_Console.windowMode.ADD_PARENTS){
console.insertTextOut("The node \"" + selectedObjects +"\" was selected.");
} else if (console.wMode == windowMode.JOIN_RELATIONS) {
} else if (console.wMode == HMLP_Console.windowMode.ADD_CLD){
console.insertTextOut("The CLD \"" + selectedObjects +"\" was selected.");
} else if (console.wMode == windowMode.LEARNING) {
} else if (console.wMode == windowMode.EVALUATION) {
}
}
}
}
});
// Expand all
for (int i = 0; i < tree.getRowCount(); i++)
tree.expandRow(i);
return new JScrollPane(tree);
}
示例14: expandAllNodes
import javax.swing.JTree; //导入方法依赖的package包/类
/**
* Expands all the nodes from the tree
*
* @param tree
* - tree rows to expand
* @param startingIndex
* - starting row index
* @param rowCount
* - end row index
*/
public static void expandAllNodes(JTree tree, int startingIndex, int rowCount) {
for (int i = startingIndex; i < rowCount; ++i) {
tree.expandRow(i);
}
if (tree.getRowCount() != rowCount) {
expandAllNodes(tree, rowCount, tree.getRowCount());
}
}