Enable/Disable uitabs in uitabgroup, with v2015b

조회 수: 10 (최근 30일)
Antoine Luijkx
Antoine Luijkx 2015년 10월 3일
답변: Sean de Wolski 2020년 11월 6일
In a GUI, is there a way to disable/enable a tab created by uitabgroup / uitab.
In a GUI I'm building, I would like to prevent the user from accessing some tabs at earlier stage of the process, and then grant access later when some operations are done in the GUI.
In following example:
fig=figure();
tabgroup=uitabgroup('Parent',fig);
tab1=uitab(tabgroup,'title','title1');
tab2=uitab(tabgroup,'title','title2');
I would like to disable tab2 (something like set(tab2,'Enable','off') would be nice).
It was possible with previous release (I tested with v2013a) using the following sequence:
jtabgroup=getappdata(handle(tabgroup),'JTabbedPane');
jtabgroup.setEnableAt(1,0);
... but I can't make it work using v2015b.
Thank you,
Antoine
  댓글 수: 1
Bin Makhashen
Bin Makhashen 2015년 11월 20일
I got the same issue, please any expert help us!

댓글을 달려면 로그인하십시오.

채택된 답변

Lynn
Lynn 2016년 4월 28일
To access the underlying Java object, use FindJObj.
Try replacing
jtabgroup=getappdata(handle(tabgroup),'JTabbedPane');
jtabgroup.setEnableAt(1,0);
With
jtabgroup=findjobj(tabgroup);
jtabgroup.setEnableAt(1,0);
  댓글 수: 3
Bharath
Bharath 2016년 5월 24일
Hi,
I tried to apply your solution for my situation where I wanted to disable complete tabgroup. However when I use
jtabgroup=findjobj(tabgroup);
jtabgroup.setEnableAt(false); % also I tried turning enable off for
% for individual tabs using setEnabledAt(1,0)
I get an error saying
Undefined function 'setEnabled' for input arguments of type 'handle.handle'.
It would be extremely helpful if you can help me with this issue. Thanks in advance.
MatMar
MatMar 2016년 9월 29일
Not sure whether your question is still uptodate:
I am using Matlab 2014b.
handles = findjobj(tabgroup)
handles = findjobj(tabgroup)
returns four handles in my case.
If I use
handles(4).setEnabledAt(index,true)
it works.
Best regards Marius

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

David Young
David Young 2015년 11월 20일
A quick thought - how about using the SelectionChangedFcn callback of the uitabgroup object, to select another tab when one of the forbidden tabs is slected?
  댓글 수: 1
Antoine Luijkx
Antoine Luijkx 2015년 11월 21일
Thank you for proposal. That's indeed a workaround I have in mind. However, that's not fully satisfactory, as user can't see if a tab is enabled or not before clicking on it.

댓글을 달려면 로그인하십시오.


Sean de Wolski
Sean de Wolski 2020년 11월 6일
In App designer this is possible by adding a panel inside the uitab and disabling the uipanel.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by