1

I am trying to create an app with many text areas (80x12) in a gridlayout. I want to fill each grid with a individual text taken from a cell array. However, in the code example below I am just using {['test1',newline,'test2']} for all of them. But in the real example each text.value is different. I am looping over each textarea in the gridlayout and it is working as intended. However, it takes FOREVER (75.101076 seconds). Is there a way to speed up the process?

tic        
fig = uifigure('Position',[100 100 440 320]);
%fig.WindowState = 'maximized';
g = uigridlayout(fig,[80 12],'Scrollable','on');
g.ColumnSpacing = 0;
g.RowSpacing = 0;
g.ColumnWidth = {150,50,20,50,150,50,50,50,50,50,150,'fit'};
g.RowHeight = {50,50,50,50,50,50,50,50,50,50,...
    50,50,50,50,50,50,50,50,50,50,...
    50,50,50,50,50,50,50,50,50,50,...
    50,50,50,50,50,50,50,50,50,50,...
    50,50,50,50,50,50,50,50,50,50,...
    50,50,50,50,50,50,50,50,50,50,...
    50,50,50,50,50,50,50,50,50,50,...
    50,50,50,50,50,50,50,50,50,50};
for j = 1:12   
    for i = 1:80
        txa = uitextarea(g,'Value', {['test1',newline,'test2']});
        txa.Layout.Row = i;
        txa.Layout.Column = j;
        if i == 3
        txa.BackgroundColor = 'yellow';
        end
        if i == 8 && j == 5
        txa.BackgroundColor = 'green';
        end          
    end
end
toc

Elapsed time is 75.101076 seconds. Below is an example of the output enter image description here

Birch78
  • 71
  • 10
  • Any reason you're not just using a single uitable? – Wolfie May 16 '20 at 15:59
  • The only reason is that I am unable to do multi-line, like in my example with test1 and test2, in cells in uitable. – Birch78 May 16 '20 at 16:02
  • You might find the GUI Layout Toolbox useful here, I've found it much more performant than the in-built app tools and it is well established. You wouldn't have to change much of the above code to make it work... https://uk.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox – Wolfie May 16 '20 at 16:25
  • Thanks Wolfie, I will look into the Toolbox. – Birch78 May 16 '20 at 16:34

0 Answers0