Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

setpixelposition - Set component position in pixels

Syntax

setpixelposition(handle,position)
setpixelposition(handle,position,recursive)

Description

setpixelposition(handle,position) sets the position of the component specified by handle, to the specified position relative to its parent. position is a four-element vector that specifies the location and size of the component: [pixels from left, pixels from bottom, pixels across, pixels high].

setpixelposition(handle,position,recursive) sets the position as above. If Boolean recursive is true, the position is set relative to the parent figure of handle.

Example

This example first creates a push button within a panel.

f = figure('Position',[300 300 300 200]);
p = uipanel('Position',[.2 .2 .6 .6]);
h1 = uicontrol(p,'Style','PushButton','Units','normalized',...
               'String','Push Button','Position',[.1 .1 .5 .2]);

The example then retrieves the position of the push button and changes its position with respect to the panel.

pos1 = getpixelposition(h1);
setpixelposition(h1,pos1 + [10 10 25 25]);

See Also

getpixelposition, uicontrol, uipanel

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS