java中treenode的使用_Java TreeNode.isLeaf方法代码示例

java中treenode的使用_Java TreeNode.isLeaf方法代码示例importjavax.swing.tree.TreeNode;//导入方法依赖的package包/类publicstaticbooleanfindString(ProfilerTabletable,Stringtext,booleanmatchCase,booleannext){introwCount=table.getRowCount();ProfilerTre…

import javax.swing.tree.TreeNode; //导入方法依赖的package包/类

public static boolean findString(ProfilerTable table, String text, boolean matchCase, boolean next) {

int rowCount = table.getRowCount();

ProfilerTreeTable treeTable = null;

if (rowCount == 0) {

ProfilerDialogs.displayWarning(MSG_NODATA, ACTION_FIND, null);

return false;

} else if (rowCount == 1) {

if (!(table instanceof ProfilerTreeTable)) return false;

treeTable = (ProfilerTreeTable)table;

TreeNode node = treeTable.getValueForRow(0);

if (node == null || node.isLeaf()) return false;

}

if (treeTable != null || table instanceof ProfilerTreeTable) {

if (treeTable == null) treeTable = (ProfilerTreeTable)table;

return findString(treeTable, text, matchCase, next, null);

} else {

table.putClientProperty(LAST_FIND_TEXT, text);

table.putClientProperty(LAST_FIND_MATCH_CASE, matchCase);

if (!matchCase) text = text.toLowerCase();

int mainColumn = table.convertColumnIndexToView(table.getMainColumn());

int selectedRow = table.getSelectedRow();

boolean fromSelection = selectedRow != -1;

if (!fromSelection) selectedRow = next ? 0 : rowCount – 1;

else selectedRow = next ? table.getNextRow(selectedRow) :

table.getPreviousRow(selectedRow);

int searchSteps = fromSelection ? rowCount – 1 : rowCount;

for (int i = 0; i < searchSteps; i++) {

String value = table.getStringValue(selectedRow, mainColumn);

if (!matchCase) value = value.toLowerCase();

if (value.contains(text)) {

table.selectRow(selectedRow, true);

return true;

}

selectedRow = next ? table.getNextRow(selectedRow) :

table.getPreviousRow(selectedRow);

}

ProfilerDialogs.displayInfo(MSG_NOTFOUND, ACTION_FIND, null);

return false;

}

}

今天的文章java中treenode的使用_Java TreeNode.isLeaf方法代码示例分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/9212.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注