MATLAB Answers

0

How do you enable a slider to scroll an entire panel?

Cordelle 님이 질문을 제출함. 12 Jun 2013
최근 활동 Selby 님이 답변함. 6 Dec 2016
So far, I have only succeeded in scrolling the contents in the panel. However, I want the whole panel to scroll along with the content.
any form of help will be highly appreciated
Thanks in advance, Cordel Williams

  댓글 수: 0

로그인 to comment.

답변 수: 2

Answer by Walter Roberson
on 12 Jun 2013

If you have contents of an axes (lines, surfaces, drawn text) that you want to move while the axes itself stays in one location, then use panning to adjust what is visible in the axes (by either using the pan tool, or by adjusting the axes XLim and YLim)
When you have a collection of objects that are to be moved within a figure while the figure itself stays in one place, such as the position of axes, or position of controls relative to the figure edge, then put the collection inside a uipanel and have slides adjust the location of the uipanel relative to the figure.
The above is enough in most cases, but if you need a uipanel itself to move, then put the uipanel within a uipanel. And if you need that to move, put it within a uipanel. And so on. It's uipanels all the way down!

  댓글 수: 4

표시 이전 댓글 수: 1
I have a uipanel2 within a uipanel1 in my GUI.
p1 = uipanel(...)
p2 = uipanel(..., 'Parent', p1);
p2 is now contained within p1, and if you change the Position property of p2, you will be changing the position relative to p1
the thing is that i used Guide to create the panels

로그인 to comment.


Answer by Selby
on 6 Dec 2016

g=figure;
u=uipanel(g,'backgroundcolor',[1 0 1],'units','pixels','position',[1000 1000 g.InnerPosition(3)-19 1000]);
uu=findjobj(u);
j=javax.swing.JScrollPane(uu);
j.setHorizontalScrollBarPolicy(j.HORIZONTAL_SCROLLBAR_NEVER);
[jj hh]=javacomponent(j,[10 10 g.InnerPosition(3)-20 g.InnerPosition(4)-20],g);
%components to add to panel
button=uicontrol(u,'style','pushbutton','units','pixels',...
'position',[0.1 0.1 100 100],'string','blah');
This uses Yair's findjobj

  댓글 수: 0

로그인 to comment.



Translated by