Search code examples
matlabmatlab-figure

How to keep figure in focus, no matter what


How do I keep a figure in focus of my system, even when I click on other things, outside of MATLAB? The idea is to 'pin a figure' on top, like an important forum post.


Solution

  • This page illustrates how it can be done.


    An example:

    First, create the figure:

    figure
    f = gcf;
    

    Then, use JavaFrame undocumented magic:

    fJFrame = get(f,'JavaFrame');
    jClient = fJFrame.fHG2Client;
    jWindow = jClient.getWindow;
    jWindow.setAlwaysOnTop(true);
    

    All credits to Yair Altman.