Clear Filters
Clear Filters

Created tabbed GUI in GUIDE

44 views (last 30 days)
Justin Solomon
Justin Solomon on 26 May 2015
Commented: beginner94 on 22 Oct 2019
Is there any way to lay out and design a GUI with tabs using GUIDE? I don't see any place to insert uitabgroup panels with GUIDE. I fear I may have to go back to basics and program everything from scratch. Yikes!
Joseph Cheng
Joseph Cheng on 26 May 2015
what do you have now that would make you go back to scratch?
Justin Solomon
Justin Solomon on 27 May 2015
I haven't actually started making the GUI, but I know that I will want to use tabs. When I said "from scratch" I meant that I will have to make the GUI programmatically instead of using GUIDE.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 27 May 2015
No, GUIDE doesn't do that now, unfortunately. Hopefully in the next release, because you can do it from scratch, in code, like you said. However if you have dozens of other widgets on your UI, creating them all would be a major pain. One workaround is to use buttons as tabs and put all the controls that you would have placed on a tab into a panel. Put the buttons into a button group so that when you press one, it "unpresses" the others and makes the appropriate panel visible and the others invisible. Kind of kludgy but it works.

More Answers (4)

Charles on 29 May 2015
Edited: Charles on 29 May 2015
I have discovered the same issue. I primarily do my GUI's with Guide, and would like to continue. Here is my workaround:
  1. Make a GUIDE figure large enough to hold all of your tabs side-by-side
  2. Create panels side-by-side on the GUIDE page. Tag them P1, P2, etc. Make the panels all the same size, set the border to "none", and clear the title (if desired)
  3. Place panel 1 where you want all the panels to be. Be sure to leave room on the left if you are using left tabs. the location of the rest of the panels does not matter. Make sure panel 1 is the same size or larger than all of your other panels. The remaining panels should leave some space away form panel 1 so that you will be able to grab and drag the figure corner when editing later.
  4. Lay out all of your buttons, text boxes, and other features within each panel.
  5. When done with the layout, shrink the overall window in GUIDE to just show panel 1. the other panels continue to exist, off the page.
  6. Edit the corresponding .m file, OpeningFCN, adding a version of the following code:
%Create tab group
handles.tgroup = uitabgroup('Parent', handles.figure1,'TabLocation', 'left');
handles.tab1 = uitab('Parent', handles.tgroup, 'Title', 'My Tab Label 1');
handles.tab2 = uitab('Parent', handles.tgroup, 'Title', 'My Tab Label 2');
handles.tab3 = uitab('Parent', handles.tgroup, 'Title', 'My Tab Label 3');
%Place panels into each tab
%Reposition each panel to same location as panel 1
Now all of the controls end up on the correct tabs within hidden panels. To edit panel content, in GUIDE expand the figure to see all the panels, edit, then shrink again.
This approach allows the use of GUIDE and has minimal programming to arrange your GUIDE elements into the tabs.
Hope this helps!
qaqcvc on 30 Jul 2019
Thanks! It works very well.
beginner94 on 22 Oct 2019
Thanks a lot for this workaround!
Do you also know how to resize of the overall window when another tab is opened?

Sign in to comment.

Walter Roberson
Walter Roberson on 26 May 2015
It appears that GUIDE does not offer a layout service for tab groups. However, see

Ka Mirul
Ka Mirul on 25 Nov 2018
You can use several button to switch panel dispaly to create multi tab GUI.
I've made step by step tutorial here. Enjoy

egdeluca on 25 Sep 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(;
% Now let's prepare the close button: icon, size and callback
jCloseButton = handle(javax.swing.JButton,'CallbackProperties');
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');
% 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


Find more on Migrate GUIDE Apps in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!