本文整理匯總了Java中javax.swing.tree.DefaultMutableTreeNode.getAllowsChildren方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultMutableTreeNode.getAllowsChildren方法的具體用法?Java DefaultMutableTreeNode.getAllowsChildren怎麽用?Java DefaultMutableTreeNode.getAllowsChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.tree.DefaultMutableTreeNode
的用法示例。
在下文中一共展示了DefaultMutableTreeNode.getAllowsChildren方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toggle
import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
private boolean toggle(TreePath treePath) {
if( treePath == null ) {
return false;
}
Object o = ((DefaultMutableTreeNode)treePath.getLastPathComponent()).getUserObject();
DefaultTreeModel dtm = (DefaultTreeModel)cfgTree.getModel();
DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();
if ( o instanceof Item ) {
Item item = (Item)o;
if ( node.getAllowsChildren() ) {
return false;
}
item.value = !item.value;
dtm.nodeChanged(node);
dtm.nodeChanged(node.getParent());
scs.notifyChanged();
}
return false;
}
示例2: valueChanged
import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
@Override
public void valueChanged(TreeSelectionEvent e) {
TreePath[] paths = getSelectionPaths();
// If only one item has been selected, then change the text in the
// description area
if (paths == null) {
return;
}
if (paths.length == 1) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[0].getLastPathComponent();
if (!node.getAllowsChildren()) {
ClusterTreeLeaf leaf = (ClusterTreeLeaf) node.getUserObject();
ObjectVisualizer viz = ObjectVisualizerService.getVisualizerForObject(clusterModel);
viz.startVisualization(leaf.getId());
}
}
}
示例3: actionPerformed
import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e)
{
// Ask for name
String name = (String) JOptionPane.showInputDialog(getParent(), s("dialog.newfolder.desc"),
s("dialog.newfolder.title"), JOptionPane.PLAIN_MESSAGE, null, null, null);
// Have they entered a name?
if( name != null )
{
String path = rootFolder;
// Check for selection
if( !fileTree.isSelectionEmpty() )
{
TreePath selectionPath = fileTree.getSelectionPath();
DefaultMutableTreeNode lastPathComponent = (DefaultMutableTreeNode) selectionPath
.getLastPathComponent();
if( lastPathComponent.getAllowsChildren() )
{
path = getSelectedPath(selectionPath);
}
else
{
path = getSelectedPath(selectionPath.getParentPath());
}
}
service.createFolder(stagingID, path, name);
fileTreeModel.reload();
}
}
示例4: isLeaf
import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
@Override
public boolean isLeaf(Object node)
{
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) node;
return !treeNode.getAllowsChildren();
}