フィルターのクリア

Uitab problems with R2019a

3 ビュー (過去 30 日間)
egdeluca
egdeluca 2019 年 9 月 25 日
コメント済み: egdeluca 2019 年 9 月 25 日
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 件のコメント
egdeluca
egdeluca 2019 年 9 月 25 日
Thanks for your informations.
Egidio
egdeluca
egdeluca 2019 年 9 月 25 日
I solved, thanks.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangePlatform and License についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by