Code covered by the BSD License  

Highlights from
Scrollbar GUI Example

image thumbnail
from Scrollbar GUI Example by Juergen Reimers
GUI with a working scrollbar, that moves other GUI elements.

GUIexample.m
screensize=get(0,'ScreenSize');
%Build larger figure than normal, value of Position is pixel, starting down left corner
fig=figure('Position',[100 100 screensize(3)-150 screensize(4)-150]);

%Build a Panel inside figure, value of Position is from 0-1 (1=size of
%figure), parent for other GUI elements
hpanel=uipanel(fig,'Position',[0.2 0.2 0.6 0.6]);

%Build subpanel as a child of, value of Position is from 0-1 (1=size of
%hpanel)
hsp = uipanel('Parent',hpanel,'Title','Subpanel','FontSize',12,...
              'Position',[.4 .1 .5 .5]);
          
%set axes inside subpanel, for plots 
blob=axes('Parent',hsp);    

%This button is situated in hpanel (value of Position is pixel), but plots in hsp
hbsp = uicontrol('Parent',hpanel,'Style','pushbutton','String','Push here',...
              'Position',[18 18 72 36],'Callback','plot(1:10,1:10)');
          
%This slider is in figure, but not a child of hpanel, it's fixed 
%whenever it is touched, it calls the routine slider
hpop = uicontrol('Style', 'slider',...
       'String', 'drueck',...
       'Position', [20 320 50 100],...
       'Callback', 'slider');
   
%normally, sliders start with value=0, which means slider is down, fixed
%here

set(hpop,'Value',1);

%get initial hpanel value for sliding
pos=get(hpanel,'Position');   

Contact us at files@mathworks.com