www.gusucode.com > GUI的布局工具箱 > GUI的布局工具箱/GUI的布局工具箱/GUILayout-v1p10/layoutHelp/Examples/visibleexample.m

    %% Showing/hiding a panel
%
%   This example opens a simple user-interface with a panel full of
%   buttons. We can then show/hide the entire panel in one go. Note
%   that the previous state of the buttons is preserved. 

%% Open a window and add a panel
fig = figure( 'Name', 'Visible example', ...
    'Position', [100 100 150 250], ...
    'MenuBar', 'none', ...
    'ToolBar', 'none', ...
    'NumberTitle', 'off' );
panel = uiextras.BoxPanel( 'Parent', fig, 'Title', 'Panel' );

%% Put some buttons inside the panel
box = uiextras.VButtonBox( 'Parent', panel );
uicontrol( 'Parent', box, 'String', 'Button 1' );
uicontrol( 'Parent', box, 'String', 'Button 2' );
uicontrol( 'Parent', box, 'String', 'Button 3', 'Visible', 'off' );
uicontrol( 'Parent', box, 'String', 'Button 4' );
uicontrol( 'Parent', box, 'String', 'Button 5', 'Visible', 'off' );
uicontrol( 'Parent', box, 'String', 'Button 6' );

%% Try disabling the panel
set( panel, 'Visible', 'off' );

%% Try enabling the panel
set( panel, 'Visible', 'on' );