I want it to open in maximized mode. How can I do this? I am running
Matlab 2007a.
you can do like that
fig = figure
set(fig,'units','normalized','outerposition',[0 0 1 1]);
plot(x,y)
By the way, you could find more detail with key word:
maximized window figure in search section.
Here is another pretty code:
jf =get(gcf,'JavaFrame');
jf.fClientProxy.getFrameProxy.getClientFrame.setMaximized(1)
the simplest way how to place figure window on the full
screen is to call "fig(5);"
function fig.m for figure window placement in the coded
position can be found in FEX Id: 9035.
Mira
> Here is another pretty code:
> jf =get(gcf,'JavaFrame');
> jf.fClientProxy.getFrameProxy.
getClientFrame.setMaximized(1)
I couldn't get that to work (in R2007b).
For the first line, I get
jf = com.mathworks.hg.peer.FigurePeer@1a8a9e7
And then the 2nd line gives me this error:
??? No appropriate method or public field com for class
com.mathworks.hg.peer.FigurePeer.
> the simplest way how to place figure window on the full
> screen is to call "fig(5);" (FEX Id: 9035.)
As Einstein said, things should be as simple as possible
but no simpler. This one is too simple. Perhaps this can
be done with some complex .m code, I don't know. For one
thing the .48 constant is not going to work for all screen
resolutions and configurations. To make matters worse, you
don't want the figure to overlap the task bar, and you
don't know where that is (top, bottom, left, right), nor
how big it is.
I wish I had a .m routine that could do this, but so far
I haven't found it. Now I do this with the
winshowwin(figHandle,'maximize') function which is part
of the Mpacks package from www.soundslogical.com.
(Its primary drawback is that it costs $40)
~Paul
Here's a small fix for R2007b:
jf=get(gcf,'JavaFrame');
awtinvoke(jf.fFigureClient.getFrameProxy,'setMaximized(Z)',1);
Yair Altman
http://ymasoftware.com
Thanks Yair Altman! You're right.
In MATLAB Version 7.1 (R14) (or older), we use
jf=get(gcf,'JavaFrame');
awtinvoke(jf.fClientProxy.getFrameProxy,'setMaximized(Z)',1);
and in MATLAB Version 7.2.(R2006a) (or later), we have
awtinvoke(jf.fFigureClient.getFrameProxy,'setMaximized(Z)',1);
or
jf.getFigurePanelContainer.getComponent(0).getTopLevelAncestor.setMaximized(1)
Anh Huy Phan
RIKEN - BSI
> jf=get(gcf,'JavaFrame');
>
> awtinvoke(jf.fFigureClient.getFrameProxy,'setMaximized
(Z)',1);
you could also use:
set(jf,'Maximized',1);
Best regards,
Stephan Hoffmann
Running Yair's code(s):
jf.getFigurePanelContainer.getComponent(0).getTopLevelAncestor.setMaximized(1)
Results in:
??? Attempt to reference field of non-structure array.
Code:
awtinvoke(jf.fFigureClient.getFrameProxy,'setMaximized(Z)',1);
jf.getFigurePanelContainer.getComponent(0).getTopLevelAncestor.setMaximized(1)
Results in:
Exception while dispatching java method:
java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
... and a slew of similar messages
I'm running version 7.5.0.342 (R2007b) on Win Xp and I know zip about java programming. ;-)
Thanks
I can get the code to work if I run it line by line in the command window NOT if run it from within a script or a function.
The reason is that using jf (the Java Frame) requires the figure window to be visible, and in your code you probably try to maximize the window while its 'visible' property is 'off'.
Yair Altman
The figure's visible property is 'on'.
However, by adding a pause before retrieving the JavaFrame handle the code suddenly worked...
h = figure;
pause(0.01) %<== Adding this line made it all work...
jf=get(h,'JavaFrame');
set(jf,'Maximized',1);
I have no clue why it worked but sometimes, I guess, ignorance is bliss.
Thanks guys!
figure('name',mfilename,...
'NumberTitle','off','Position',[20 20 700 500],...
'Color',[0.45 0.25 .05]);