User guide previous pagenext page

3.2: Visible example Go back up one level

(The code for this example can be found here: [ view | edit | run ] )

This example shows how the visible property can be used to hide whole sections of an interface.

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 hiding the panel
set( panel, 'Visible', 'off' );

Try showing the panel. Note that the original "visible" state of each button is remembered.
set( panel, 'Visible', 'on' );


© 2014 The MathWorks Ltd Terms of Use Patents Trademarks