Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7196249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:44:34+00:00 2026-05-28T20:44:34+00:00

I am trying to make a Matlab GUI that has a panel with scrolling

  • 0

I am trying to make a Matlab GUI that has a panel with scrolling content inside of a larger figure. I am having a problem hiding the overflow content when it scrolls out of the subpanel.

I got the code for the scrollbar from this SO post: Adding scroll bar in subplots within GUI

Try the code below. I have a figure, an outer panel (smaller than the figure, child to the figure), a scrolling panel (with a height greater than the figure, child to outer panel), a scroll bar, and a text field to appear in the scrolling pane (child to the scrolling panel).

When you try the code you will see the text string, which is just the alphabet repeated, scrolls up and down the whole length of the figure, but the scrolling panel stops at the edge of the limits of the outer panel.

How can I correct this problem. Thanks.

function guitest
    scrsz = get(0,'ScreenSize');

    height = scrsz(4)*7/8;
    width = scrsz(3)*2/3;
    leftmargin = 10;
    rightmargin = 10;

    % figure 
    handles.hFig = figure('Visible','on',...
                    'Position', [scrsz(3)/8 scrsz(4)/10 width height],...
                'Name', 'Tap Toolbar Report',...
                'NumberTitle', 'off',...
                'Color', [0.75 0.75 0.75],...
                'ToolBar','none',...
                'MenuBar','none',...
                'Resize','off');

    % subpanel in the figure for scrolling
    handles.hOut = uipanel('Parent',handles.hFig,...
                  'BackgroundColor', [0.85 0.85 0.85],...
                  'BorderWidth', 0,...
                  'Units', 'pixels',...
                  'Position',[leftmargin 100 width-2*leftmargin height-200]);

    hPanheight = 2000;

    handles.hPan = uipanel('Parent',handles.hOut,...
              'BackgroundColor', [0.85 0.85 0.85],...
              'BorderWidth', 0,...
              'Units', 'pixels',...
              'Position',[0 0 width-2*leftmargin-19 hPanheight]);

    str = sprintf('a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz');
    uicontrol('Parent', handles.hPan,'Style','text','String',str,'FontSize', 10,'FontWeight','bold', 'HorizontalAlignment', 'left',...
            'Position',[10 20 20 1960],'BackgroundColor', [0.85 0.85 0.85]);          

    handles.hSld = uicontrol('Style', 'slider',...
                'BackgroundColor', [0.8 0.8 0.8], ...
                'Position', [width-leftmargin-20 101 19 height-202],...
                'Callback', {@onSlide,handles.hPan,handles.hOut});
    set(handles.hSld,'Value',1);
    onSlide(handles.hSld,'',handles.hPan,handles.hOut)
end 

function onSlide(hSld,~,hPan,hOut)
    %# slider value
    offset = get(hSld,'Value');

    %# update panel position
    p = get(hPan, 'Position');  %# panel current position
    ph = get(hOut, 'Position');
    set(hPan, 'Position',[p(1) -offset*(p(4)-ph(4)) p(3) p(4)])
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:44:35+00:00Added an answer on May 28, 2026 at 8:44 pm

    I would use a container object that has scroll capability built-in. Take a look at:

    help uitable
    help uitree
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

trying to make one horizontal box.. inside that update limits. if u see the
Trying to make a make generic select control that I can dynamically add elements
Trying to make a custom :confirm message for a rails form that returns data
Im trying to make a function that will return an element of type point:
I'm trying to make a program that roughly does the following: produceBeepSound(double loudness); can
I trying to make a web service accessible to Matlab. I can call it
I am trying to make a loop to redo a Matlab function 1000 times.
Trying to make infoWindows a little less uglier I found out that the infoWindows
I am trying to make a program which maps coordinates. I am having trouble
Trying to make a regex that can handle input like either: Beverly Hills, CA

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.