本文整理汇总了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();
}