Why is my GUI Slider dissapearing when I set it's position?!
Show older comments
This is a very frustrating little problem!!
I'm constructing a GUI, and have decided I want to do it programtically, rather than with GUIDE, so as to have more control.
The interface has 4 axes and a slider. It will soon have more objects, so I've left the bottom 30% of the figure clear (Units Normalized = 0.3).
Attached is the code, which: when I run it (I'm using 2011b) the slider is not shown. Annoyingly, though, if I then execute the last line from the command window, it appears where I want it to!! So I've added the same line in immediately after itself and....low and behold the code works!!
This seems a bit clunky and messy....and I'd like to know what's going on and why this is happening.
Anyone any ideas as to why this is going on??
Regards in advance,
Gav
clear all;
close all;
clc;
%%DEVELOP GUI FIGURE INTERFACE
%%Interface Layout Geometry
f1p=[7,19,1233,954]; %Figure Position Vector
b=30; %Percentage of bottom not consumed by axes
p=3; %Gap size between axes and between edges & axes
wa=(100-3*p)/2; %width of axes
ha=(100-b-3*p)/2; %height of axes
a1p=[p,100-(p+ha),wa,ha]/100; %Axes 1 position vector
a2p=[50+p/2,100-(p+ha),wa,ha]/100; %Axes 2 " "
a3p=[p,b+p,wa,ha]/100; %Axes 3 " "
a4p=[50+p/2,b+p,wa,ha]/100; %Axes 4 " "
s1p=[50+p/2+wa/4,b-p,wa/2,1.5]/100; %Slider 1 Position Vector
%%Generate Objects and Position Accordingly
f1=figure(); %Figure 1
set(f1,'Position',f1p); %Position
a1=axes(); %Axes 1-4
a2=axes();
a3=axes();
a4=axes();
set(a1,'Position',a1p,'Units','Normalized'); %Position Axes
set(a2,'Position',a2p,'Units','Normalized');
set(a3,'Position',a3p,'Units','Normalized');
set(a4,'Position',a4p,'Units','Normalized');
s1=uicontrol(f1,'Style','Slider'); %Slider 1
set(s1,'Position',s1p,'Units','Normalized'); %Position Slider
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!