Sie sind auf Seite 1von 6

12/9/12

Uitab customizations | Undocumented Matlab

Undocumented Matlab
Charting Matlabs unsupported hidden underbelly

Uitab customizations
Wednesday, November 17th, 2010

Welcome Googler! If you find this page useful, you might want to subscribe to the RSS feed or email 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 to present 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:
%P r e v e n ta na n n o y i n gw a r n i n gm s g w a r n i n go f fM A T L A B : u i t a b g r o u p : O l d V e r s i o n %P r e p a r eat a b g r o u pc o n s i s t i n go ft w ot a b s h T a b G r o u p=u i t a b g r o u p ;d r a w n o w ; t a b 1=u i t a b ( h T a b G r o u p ,' t i t l e ' , ' P a n e l1 ' ) ; a=a x e s ( ' p a r e n t ' ,t a b 1 ) ;s u r f ( p e a k s ) ; t a b 2=u i t a b ( h T a b G r o u p ,' t i t l e ' , ' P a n e l2 ' ) ; u i c o n t r o l ( t a b 2 ,' S t r i n g ' , ' C l o s e ' ,' C a l l b a c k ' , ' c l o s e ( g c b f ) ' ) ; %G e tt h eu n d e r l y i n gJ a v ar e f e r e n c e( u s eh i d d e np r o p e r t y ) j T a b G r o u p=g e t a p p d a t a ( h a n d l e ( h T a b G r o u p ) , ' J T a b b e d P a n e ' ) ;

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:
j T a b G r o u p . s e t E n a b l e d A t ( 1 , f a l s e ) ; %d i s a b l eo n l yt a b# 1( = s e c o n dt a b ) j T a b G r o u p . s e t E n a b l e d ( f a l s e ) ; %d i s a b l ea l lt a b s j T a b G r o u p . s e t E n a b l e d ( t r u e ) ; %r e e n a b l ea l lt a b s( e x c e p tt a b# 1 )

undocumentedmatlab.com/blog/uitab-customizations/

1/6

12/9/12

Uitab customizations | Undocumented Matlab

A disabled tab

Note that setting the property value for a specific tab overrides the value set for ALL tabs, despite the fact that setEnabled is called after setEnabledAt.

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

Plastic3DLookAndFeel

MotifLookAndFeel

undocumentedmatlab.com/blog/uitab-customizations/

2/6

12/9/12

Uitab customizations | Undocumented Matlab

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 reported problem when compiling any GUI that includes it; a reported bug when reordering tabs; a reported problem rendering some graphic object properties (e.g., clipping); and a reported problem in displaying tabs containing ActiveX or Java objects (plus suggested solutions). Interested readers can fix all these issues by 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 Manager utility. 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 images Matlab's semi-documented tab panels can be customized using
some undocumented hacks...
undocumentedmatlab.com/blog/uitab-customizations/ 3/6

12/9/12

Uitab customizations | Undocumented Matlab

2. Tab panels uitab and relatives This article describes several undocumented Matlab functions
that support tab-panels...

3. Figure toolbar customizations Matlab'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 utility ExploreStruct is a utility that shows how custom uitrees can be
integrated in Matlab GUI...

5. Figure toolbar components Matlab'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 uitree This 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 Up to

Print

If you like this post, please consider buying me a cup of coffee.

7 Responses to Uitab customizations


Jason says:
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

Gina says:
March 16, 2011 at 6:43 am

undocumentedmatlab.com/blog/uitab-customizations/

4/6

12/9/12

Uitab customizations | Undocumented Matlab

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 Altman says:


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/

sebbo says:
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=u i c o m p o n e n t (t a b 1 ,' s t y l e ' ,' J T e x t F i e l d ' ,' T e x t ' ,' H e l l o ' ) ;

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 Altman says:


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).

Limo says:
June 21, 2012 at 7:27 am

Hi,
undocumentedmatlab.com/blog/uitab-customizations/ 5/6

12/9/12

Uitab customizations | Undocumented Matlab

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 Altman says:


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.

Undocumented Matlab Entries (RSS) and Comments (RSS). Copyright 2009-2010 Yair Altman

undocumentedmatlab.com/blog/uitab-customizations/

6/6

Das könnte Ihnen auch gefallen