Reputation: 1744
I have a problem to see the tree structure created by the following code. I want the tree box fulfills the interior of the pane which handle is hPanLeft. However, if I use normalized units, I get NaN and Inf for the Position property of the tree structure. I do not understand what is wrong.
function example
import javax.swing.*
import javax.swing.tree.*;
f = figure;
hPanRight = uipanel('Parent',f,'Units','normalized','Position',...
[0.5 0 0.5 0.5]);
hPanLeft = uipanel('Parent',f,'Units','normalized','Position',...
[0 0.5 0.5 0.5]);
[tree, container]= uitree('v0');
set(container,'Parent',hPanLeft);
set(tree, 'Units', 'normalized');
set(tree,'Position',[0 0 1 1]);
get(tree,'Position'),
root = uitreenode('v0','root','MAIN',[],false);
Nodo1 = uitreenode('v0','Nodo1','LEAF 1',[],true);
Nodo2 = uitreenode('v0','Nodo2','LEAF 2',[],true);
Nodo3 = uitreenode('v0','Nodo3','LEAF 3',[],true);
root.add(Nodo1);
root.add(Nodo2);
root.add(Nodo3);
treeModel = DefaultTreeModel(root);
tree.setModel(treeModel);
jtree = handle(tree.getTree,'CallbackProperties');
tree.setSelectedNode(root);
end
Upvotes: 0
Views: 4368
Reputation: 124563
You want to set the position property of the container not the tree object handle:
[tree,container] = uitree('v0');
set(container, 'Parent',hPanLeft);
set(container, 'Units','normalized', 'Position',[0 0 1 1]);
Just remember that UITREE is an undocumented function. You might want to read this series of articles on this component.
Upvotes: 1