Search code examples
matlabwindowfiguremaximize

Maximize MATLAB figure's WINDOW - not the figure


What I want is to maximize the window of the figure as if I clicked it with mouse, but not the figure itself. Because all the techniques of enlarging figure do really make it bigger, but the window remains restored though fits to the figure.

Here is the command I use to enlarge a figure:

figure ('units',' normalized', 'position', [0 0 1 1]);

The difference between enlarged window and maximized is as follows:

enlarged: enter image description here

maximized: enter image description here

Look at the top right corner of the window, which is where one clicks with a mouse to maximize/restore, see the change. See also how the maximized window fills tight the whole screen and doesn't go under the taskbar either by its color.

Thanks.


Solution

  • The answer can be found in the following article, kindly provided by the user excaza:
    http://undocumentedmatlab.com/blog/minimize-maximize-figure-window

    Essentially, it breaks down to operating the JavaFrame figure's property. It is absent in the handle, hidden from user, so just operate as if it's there.

    Pay attention to the pause factor described in the article's comments. Without it nothing works, because of some Java issues related to time shortage between figure call and Java readiness.
    It is suggested in the comments to add before the maximizing/minimizing drawnow; pause(0.1);. For me it works without drawnow;. Also, any infinitesimal argument will work for pause, if you should, like pause(1e-1000000); for example.