Upload
sdhosseini88
View
220
Download
0
Embed Size (px)
Citation preview
7/28/2019 Uitab Customizations _ Undocumented Matlab
1/6
/9/12 Uitab customizations | Undocumented Matlab
documentedmatlab.com/blog/uitab-customizations/
X
Uitab customizations
Wednesday, November 17th, 2010
Welcome Googler! If you find this page useful, you might want to subscribe to the RSS feed
oremail feed for updates on Undocumented Matlab topics.
You were searching for "uitab warning". See posts relating to your search
This article concludes my planned series on Matlabs built-in semi-documented tab-panel
functionality. In previous article I have shown how Matlabs uitab and uitabgroup
functions can be used topresent tabbed contents, and how icon images can be attached to
tabs using their undocumented underlying Java component. Today I will show other
customizations that can be done to tabs.
Disabling tabs
Our first customization is to disable particular tabs. We start with a basic tab group, and get
the underlying Java component:% Prevent an annoying warning msg
warningoff MATLAB:uitabgroup:OldVersion
% Prepare a tab-group consisting of two tabs
hTabGroup = uitabgroup; drawnow;
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');
Remember that Java uses 0-based indexing so tab #1 is actually the second tab. Lets
disable it by using the Java objects setEnabledAt() method:
jTabGroup.setEnabledAt(1,false); % disable only tab #1 (=second tab)
jTabGroup.setEnabled(false); % disable all tabs
jTabGroup.setEnabled(true); % re-enable all tabs (except tab #1)
Undocumented Matlab
Charting Matlabs unsupported hidden underbelly
7/28/2019 Uitab Customizations _ Undocumented Matlab
2/6
/9/12 Uitab customizations | Undocumented Matlab
documentedmatlab.com/blog/uitab-customizations/
A disabled tab
Note that setting the property value for a specific tab overrides the value set for ALL tabs,
despite the fact thatsetEnabledis called aftersetEnabledAt.
Look-and-Feel
Unlike some other controls, tabs have distinctly different appearances in different Look &
Feels. Take a look at Plastic3DLookAndFeel, NimbusLookAndFeel and MetalLookAndFeel
for tab panels that look distinctly different and more stylish than the WindowsLookAndFeel
shown above.
WindowsLookAndFeel WindowsClassicLookAndFeel
Plas tic3DLookAndFeel MotifLookAndFeel
7/28/2019 Uitab Customizations _ Undocumented Matlab
3/6
/9/12 Uitab customizations | Undocumented Matlab
documentedmatlab.com/blog/uitab-customizations/
MetalLookAndFeel NimbusLookAndFeel
Other customizations
There are other things we can customize, such as setting mnemonics (keyboard shortcuts),
etc. refer to the official documentation or any good textbook about Java Swing.
Tab callbacks are the same as the standard Swing components callbacks, except for
StateChangedCallback, which is automatically linked to the internal function that
synchronizes between the Java tab group and the Matlab uicontainers (in other words: its
not a good idea to mess with it).
Some jTabGroup functions that work well with standard JTabbedPane fail with uitabgroup:
For example, jTabGroup.setIconAt or setTabLayoutPolicy. I am unsure of the reason for
this. Other limitations with uitabgroup are a reportedproblem when compiling any GUI that
includes it; a reportedbug when reordering tabs; a reportedproblem rendering some graphic
object properties (e.g., clipping); and a reportedproblem in displaying tabs containing
ActiveX orJava objects (plus suggested solutions). Interested readers can fix all these issuesby modifying the m-files in the folders
%matlabroot%/toolbox/matlab/@uitools/@uitabgroup and /@uitools/@uitab. At least some
of these problems are fixed as of R2010a.
Readers might also be interested in the Yet Another Layout Managerutility. This utility
directly uses Swings JTabbedPane object to implement tab panels, essentially mimicking
the built-in uitab/uitabgroup functions.
This concludes my series on Matlabs uitab. Any other specific customizations you are
interested in? Any nice variation of your own? Please do share your thoughts in a comment.
Related posts:
1. Uitab colors, icons and imagesMatlab's semi-documented tab panels can be customized using
some undocumented hacks...
7/28/2019 Uitab Customizations _ Undocumented Matlab
4/6
/9/12 Uitab customizations | Undocumented Matlab
documentedmatlab.com/blog/uitab-customizations/
If you like this post, please consider buying me a cup of coffee.
2. Tab panels uitab and relativesThis article describes several undocumented Matlab functions
that support tab-panels...
3. Figure toolbar customizationsMatlab's toolbars can be customized using a combination of
undocumented Matlab and Java hacks. This article describes how to customize the Matlab figure
toolbar....
4. An interesting uitree utilityExploreStruct is a utility that shows how custom uitrees can beintegrated in Matlab GUI...
5. Figure toolbar componentsMatlab's toolbars can be customized using a combination of
undocumented Matlab and Java hacks. This article describes how to access existing toolbar icons and
how to add non-button toolbar components....
6. Customizing uitreeThis article describes how to customize Matlab GUI tree controls created using
the undocumented uitree function...
Categories: GUI, Java, Medium risk of breaking in future versions, Semi-documented function
Tags: GUI, Java, Semi-documented function, uitools
Like Sign
U to Print
7 Responses to Uitab customizations
Jasonsays:
November 22, 2010 at 7:43 am
FYI there is also another bug if you delete all uitabs contained in a uitabgroup in R2010b. An error
message appears because the code tries to set that new SelectedTab property to [], but it of course isnt
a child and then causes an error. It doesnt seem to affect the actual behavior, so try..catch will take
care of it (temporarily).
Reply
Ginasays:
March 16, 2011 at 6:43 am
7/28/2019 Uitab Customizations _ Undocumented Matlab
5/6
/9/12 Uitab customizations | Undocumented Matlab
documentedmatlab.com/blog/uitab-customizations/
The Look and Feel link doesnt seem to be working. Is there another post somewhere that shows
how to change the appearance of the tabs as in the images above?
Reply
Yair Altmansays:
March 16, 2011 at 6:49 am
@Gina thanks: I fixed the link in the post.
It is http://UndocumentedMatlab.com/blog/modifying-matlab-look-and-feel/
sebbosays:
March 6, 2012 at 7:11 am
Hi,
thanks!. Though this is a rather old post I found this quite helpful.
I seem to be having a problem though with using uitabs as parents for other ui-elements.
For instance, when I append this one line to your example:
t = uicomponent( tab1, 'style', 'JTextField', 'Text', 'Hello');
The result JTextField still remains visible after switching to tab2.
I seem to be having the same issue with more complex java controls too.
Any idea on how to solve this?
cheers,
sebastian
Reply
Yair Altmansays:
March 6, 2012 at 7:16 am
@Sebbo as I noted in the article, Matlab releases up to 2010 had this problem with
java controls. This problem has been fixed in either R2010a or R2010b (I forget
which).
Limosays:
June 21, 2012 at 7:27 am
Hi,
7/28/2019 Uitab Customizations _ Undocumented Matlab
6/6
/9/12 Uitab customizations | Undocumented Matlab
documentedmatlab.com/blog/uitab-customizations/
Undocumented Matlab Entries (RSS) and Comments (RSS).
Copyright 2009-2010 Yair Altman
also first of all thank u for all these amazing posts, they are so helpful!
and im trying to make a scrollpane,which basicly use the same trick in GScrollpane of Waterloo (inner
& outer & slider), but i hope all uicontrols can be hidden when they should be So i tried to use a
uitab as the inside pane, cause uitab is from JTabbedPane and in this way, lightweight, and then added
all uicontrols on it.
I thought theoretically it should work (lightweight Panel & lightweight uicontrols), but sadly it didnt.
Any idea why?
bests,
limo
Reply
Yair Altmansays:
July 13, 2012 at 12:18 am
@Limo I suggest that you contact Malcolm Lidierth, to ask him about this. He wrote
Waterloo and could probably answer your question directly.