本文整理汇总了Java中javax.swing.event.TreeSelectionEvent.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java TreeSelectionEvent.getPath方法的具体用法?Java TreeSelectionEvent.getPath怎么用?Java TreeSelectionEvent.getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.event.TreeSelectionEvent
的用法示例。
在下文中一共展示了TreeSelectionEvent.getPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入方法依赖的package包/类
public void valueChanged(TreeSelectionEvent e) {
super.valueChanged(e);
final TreePath p = e.getPath();
if (p != null) {
final DefaultMutableTreeNode node =
(DefaultMutableTreeNode) p.getLastPathComponent();
Object x[] = node.getUserObjectPath();
Configurable[] userObjectPath = new Configurable[x.length];
for (int i = 0; i < x.length; i++) {
userObjectPath[i] = (Configurable) x[i];
}
path = ArrayUtils.copyOfRange(userObjectPath, 1, userObjectPath.length);
}
else {
path = null;
}
}
示例2: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入方法依赖的package包/类
public void valueChanged(TreeSelectionEvent e) {
if (internal) return;
TreePath selected = e.getPath();
int row = selected == null ? -1 : tree.getRowForPath(selected);
try {
internal = true;
if (row != -1) selectRow(row, !tree.isChangingModel());
else clearSelection();
} finally {
internal = false;
}
}
示例3: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入方法依赖的package包/类
/**
* Tree selection changed, record info about the currently selected component
*/
public void valueChanged(TreeSelectionEvent e) {
selected = null;
TreePath path = e.getPath();
if (path != null) {
selected = (Configurable) ((DefaultMutableTreeNode) path.getLastPathComponent()).getUserObject();
selectedRow = getRowForPath(path);
updateEditMenu();
}
}
示例4: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入方法依赖的package包/类
@Override
public void valueChanged(TreeSelectionEvent event) {
TreePath path = event.getPath();
if (path.getPathCount() >= 2) {
DefaultMutableTreeNode node
= (DefaultMutableTreeNode)path.getPathComponent(1);
this.selected = (OptionGroup)node.getUserObject();
}
}
示例5: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入方法依赖的package包/类
@Override
public void valueChanged(TreeSelectionEvent e) {
if (e.getPath() != null
&& e.getPath().getLastPathComponent() instanceof ComponentNode) {
area.setText("toString(): "
+ ((ComponentNode) e.getPath().getLastPathComponent()).
getToString());
} else {
area.setText("");
}
}