本文整理匯總了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("");
}
}