Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Uitreenode icon

Subject: Uitreenode icon

From: David

Date: 29 Jul, 2010 12:56:04

Message: 1 of 3

I am trying to change the icon to a uitree node after creation.
Using the setIcon method, which exists accouring to Yair's uiinspect tool, the ccode fails at parent.setIcon(javax.swing.ImageIcon(myIcon));

with this error:

?? No method 'setIcon' with matching signature found for class 'com.mathworks.hg.peer.UITreeNode'.

Error in ==> Transceiver_v7_27>add_var_button_callback at 297
        parent.setIcon(javax.swing.ImageIcon(myIcon));
 
??? Error while evaluating uicontrol Callback


Thanks

>>>>>>This is the main tree code

iconpath = [matlabroot, '/toolbox/matlab/icons/HDF_filenew.gif'];
rootNode = uitreenode('v0','dummy', 'Root Node',iconpath, 0);
data_struct.template = 0;
set(rootNode,'UserData',data_struct)

treeModel = DefaultTreeModel( rootNode );

tree = uitree('v0');
drawnow;
tree.setModel( treeModel );
set(tree, 'Units', 'normalized',...
    'position', [0 0 .36 1.0]);

set( tree, 'NodeSelectedCallback',{@sel_cbk,h});
tree.setSelectedNode( rootNode );



>>>>>And This is from where I want to change the icon, where the error happens
nodes = tree.getSelectedNodes;
node = nodes(1);
parent = node;

 %change Icon from leaf to branch
        myIcon = [matlabroot, '/toolbox/matlab/icons/foldericon.gif'];
        parent.setIcon(javax.swing.ImageIcon(myIcon));

Subject: Uitreenode icon

From: Yair Altman

Date: 29 Jul, 2010 17:10:05

Message: 2 of 3

> I am trying to change the icon to a uitree node after creation.
> Using the setIcon method, which exists accouring to Yair's uiinspect tool, the code fails at parent.setIcon(javax.swing.ImageIcon(myIcon));
>
> with this error:
>
> ?? No method 'setIcon' with matching signature found for class 'com.mathworks.hg.peer.UITreeNode'.
>
> Error in ==> Transceiver_v7_27>add_var_button_callback at 297
> parent.setIcon(javax.swing.ImageIcon(myIcon));


Of course: if you'd actually used the uiinspect utility to look at the tree node handle, you would see that setIcon() expects a java.awt.Image object, which is different than what you try to give it (a javax.swing.ImageIcon).

You can convert a Swing ImageIcon to an AWT Image using the ImageIcon's getImage() method.

Yair Altman
http://UndocumentedMatlab.com

Subject: Uitreenode icon

From: David

Date: 29 Jul, 2010 18:23:08

Message: 3 of 3

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message <i2sclc$6p8$1@fred.mathworks.com>...
> > I am trying to change the icon to a uitree node after creation.
> > Using the setIcon method, which exists accouring to Yair's uiinspect tool, the code fails at parent.setIcon(javax.swing.ImageIcon(myIcon));
> >
> > with this error:
> >
> > ?? No method 'setIcon' with matching signature found for class 'com.mathworks.hg.peer.UITreeNode'.
> >
> > Error in ==> Transceiver_v7_27>add_var_button_callback at 297
> > parent.setIcon(javax.swing.ImageIcon(myIcon));
>
>
> Of course: if you'd actually used the uiinspect utility to look at the tree node handle, you would see that setIcon() expects a java.awt.Image object, which is different than what you try to give it (a javax.swing.ImageIcon).
>
> You can convert a Swing ImageIcon to an AWT Image using the ImageIcon's getImage() method.
>
> Yair Altman
> http://UndocumentedMatlab.com


Of course, if I ACTUALLY knew what I was doing, I would not have to ACTUALLY ask.....

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us