Once the undecorated JFrame becomes visible, we should not hide or delete the original Matlab figure, because this will stop rendering of the contents. JFrame = javaObjectEDT(.DTSingleClientFrame(jDesktop, figTitle)) Įither way, we now get a nice undecorated window containing our Matlab contents (see screenshot above). DTSingleClientFrame (jDesktop, figTitle ) )
So instead of creating a new JFrame, we could create a new instance of Matlab’s class instead, potentially solving a few problems: Matlab figures are not pure JFrame but rather a subclass ( .DTSingleClientFrame). tSize(mjc.getWidth+mjr.getX, mjc.getHeight+mjr.getY)
%tSize(mjc.getSize) % slightly incorrect by root-pane's offset % Set the JFrame's size to the Matlab figure's content size % Create a new pure-Java undecorated JFrame Mjr = jWindow.getRootPane % used for the offset below % Ensure that everything is rendered, otherwise the following will fail HButton = uicontrol('String','Close', 'Position',) HFig = figure('Name','Plot example', 'ToolBar','none', 'MenuBar','none') % Hide the Matlab figure by moving it off-screen % Reparent (move) the contents from the Matlab JFrame to the new JFrame % Set the JFrame's size to the Matlab figure's content size %tSize(mjc.getSize) % slightly incorrect by root-pane's offset % Move the JFrame's on-screen location just on top of the original getRootPane % used for the offset below % Create a new pure-Java undecorated JFrame getWindow % or: % Get the content pane's handle Mjf = get (handle (hFig ), 'JavaFrame' ) % Get the underlying Java JFrame reference handle % Ensure that everything is rendered, otherwise the following will fail drawnow HButton = uicontrol ( 'String', 'Close', 'Position', ) HFig = figure ( 'Name', 'Plot example', 'ToolBar', 'none', 'MenuBar', 'none' ) % Create a simple Matlab figure (visible, but outside monitor area)