Borrar filtros
Borrar filtros

Uitab problems with R2019a

3 visualizaciones (últimos 30 días)
egdeluca
egdeluca el 25 de Sept. de 2019
Comentada: egdeluca el 25 de Sept. de 2019
Good morning,
I'm trying to create a JTabGroup with delete icon but I have some problems to java handle object. From the following example:
% Prepare a tab-group consisting of two tabs
hTabGroup = uitabgroup;
tab1 = uitab(hTabGroup, 'title','Panel 1');
a = axes('parent', tab1); surf(peaks);
tab2 = uitab(hTabGroup, 'title','Panel 2');
uicontrol(tab2, 'String','Close', 'Callback','close(gcbf)');
% Get the underlying Java reference (use hidden property)
jTabGroup = getappdata(handle(hTabGroup),'JTabbedPane');
% First let's load the close icon
jarFile = fullfile(matlabroot,'/java/jar/mwt.jar');
iconsFolder = '/com/mathworks/mwt/resources/';
iconURI = ['jar:file:/' jarFile '!' iconsFolder 'closebox.gif'];
icon = javax.swing.ImageIcon(java.net.URL(iconURI));
% Now let's prepare the close button: icon, size and callback
jCloseButton = handle(javax.swing.JButton,'CallbackProperties');
jCloseButton.setIcon(icon);
jCloseButton.setPreferredSize(java.awt.Dimension(15,15));
jCloseButton.setMaximumSize(java.awt.Dimension(15,15));
jCloseButton.setSize(java.awt.Dimension(15,15));
set(jCloseButton, 'ActionPerformedCallback',@(h,e)delete(tab2));
% Now let's prepare a tab panel with our label and close button
jPanel = javax.swing.JPanel; % default layout = FlowLayout
set(jPanel.getLayout, 'Hgap',0, 'Vgap',0); % default gap = 5px
jLabel = javax.swing.JLabel('Tab #2');
jPanel.add(jLabel);
jPanel.add(jCloseButton);
% Now attach this tab panel as the tab-group's 2nd component
jTabGroup.setTabComponentAt(1,jPanel); % Tab #1 = second tab
The handle of JTabGroup variable is empty, then it doesn't work. The same code works in R2014a version. Can anyone tell me why?
Where is the mistake?
Thank you
Egidio
  3 comentarios
egdeluca
egdeluca el 25 de Sept. de 2019
Thanks for your informations.
Egidio
egdeluca
egdeluca el 25 de Sept. de 2019
I solved, thanks.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Platform and License en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by