Prev: Modified saturation
Next: Solving equation in Matalb
From: {{**AleX**}} on 16 Nov 2009 04:18 Dear All, I need to display some data architecture as a TreeView (like Windos Explorer) and have some return function to knwo which elements are currently selected by the user. I saw the uitree function in Matlab for such display settings but as it's undocumented an maybe not planed for next releases I prefer to go directly in Java components. The following code produce what I want : ========== f = figure; p = uipanel('Position', [0 0 .2 1]); ppos = getpixelposition(p); [tree treecontainer] = javacomponent('javax.swing.JTree', ... [0 0 ppos(3) ppos(4)], p); ================= Two questions: - How to instanciate the JTree components without using the javacomponent function (which is also unsupported) ? - How to modify the data structure : here it's display with some initial data but I don't find the way to customize it ? I other ways produce the same things please tell mel. Thanks for your help & comments. Alex
From: Yair Altman on 16 Nov 2009 06:35 "{{**AleX**}}" <alexandre.gomilar(a)gmail.com> wrote in message <db277c08-8c43-4e69-a60d-f48af2206c67(a)d10g2000yqh.googlegroups.com>... > Dear All, > > I need to display some data architecture as a TreeView (like Windos > Explorer) and have some return function to knwo which elements are > currently selected by the user. > I saw the uitree function in Matlab for such display settings but as > it's undocumented an maybe not planed for next releases I prefer to go > directly in Java components. > The following code produce what I want : > ========== > f = figure; > p = uipanel('Position', [0 0 .2 1]); > ppos = getpixelposition(p); > [tree treecontainer] = javacomponent('javax.swing.JTree', ... > [0 0 ppos(3) ppos(4)], p); > ================= > Two questions: > - How to instanciate the JTree components without using the > javacomponent function (which is also unsupported) ? > - How to modify the data structure : here it's display with some > initial data but I don't find the way to customize it ? > > I other ways produce the same things please tell mel. > > Thanks for your help & comments. > Alex You need to use undocumented functionality - I'm afraid there is no way around this. But you were on the right track. After creating the JTree, you can add/process tree nodes as explained here: http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html As an alternative, use Matlab's built-in uitree and uitreenode functions. They have a detailed help section within the files (type: "edit uitree" and "edit uitreenode"). As an alternative, download my FindJObj utility from the File Exchange and see how I implemented the tree, including nodes, node-icons, dynamic tooltips and dynamic context-menus: http://www.mathworks.com/matlabcentral/fileexchange/14317-findjobj-find-java-handles-of-matlab-graphic-objects I think I'll post an article about trees in Matlab on my UndocumentedMatlab site soon, but this should give you a head start in the meantime. Yair Altman http://UndocumentedMatlab.com
|
Pages: 1 Prev: Modified saturation Next: Solving equation in Matalb |