Proportional GUI

조회 수: 7 (최근 30일)
Ocram
Ocram 2011년 9월 19일
Hi everybody, I am working on a project where there is a GUI with buttons, edit-box, images...
I am working with my notebook, but I also need to use this application on others computers, that surely have different monitor.
I set inside Property Inspector, under Position a dimension in PIXEL of 1024x768. Anyway, if I set GUI as proportional, the size fill the monitor.
That is ok, but I would like to open the .exe and immediately fill the screen, as if I pressed the resize button on the upper left hand side.
How can I set this aspect?
Thanks

답변 (9개)

Aurelien Queffurust
Aurelien Queffurust 2011년 9월 19일
One possible solution:
jFrame = get(handle(gcf),'JavaFrame');
jFrame.setMaximized(true);
  댓글 수: 3
Ocram
Ocram 2011년 9월 19일
I tried this 2 lines of code, but doesn't work!
Jan
Jan 2011년 9월 19일
@Ocram: "Doesn't work" is not precise enough to find out, where the problem is. The code needs Java, so e.g. it fails when Matlab is started with the -nojvm flag. Or perhaps GCF does not point to the wanted figure?

댓글을 달려면 로그인하십시오.


Jan
Jan 2011년 9월 19일
Note that a full screen GUI looks overwhelming on a 27''-monitor. Therefore I'm using this to limit the size:
FigH = figure('Units', 'normalized', ...
'Position', [0,0,1,1], ...
'Visible', 'off');
set(FigH, 'Units', 'pixels');
FigPos = get(FigH, 'Position');
FigExt = min(FigPos(3:4), [1024, 768]);
set(FigH, 'Position', [FigPos(1:2), FigExt]);
set(FigH, 'Units', 'normalized');

Ocram
Ocram 2011년 9월 19일
I also tried this code:
set(gcf,'units','normalized','outerposition',[0 0 1 1])
This resize the figure, but It doesn't fill the screen as the Maximise button does.

Aurelien Queffurust
Aurelien Queffurust 2011년 9월 19일
  댓글 수: 1
Jan
Jan 2011년 9월 19일
The P-files contain your JavaFrame approach and some checks of the inputs. The different files concerning the Matlab version differ in the P-coding only.

댓글을 달려면 로그인하십시오.


Ocram
Ocram 2011년 9월 19일
Hi, I tried these P-files
If I write: figure, maxfig(gcf,1)
the figure fill the screen completely!!
Instead, writing this code inside the GUI, in the openingFnc maxfig(handle.figure1,1)
the figure doesn't change aspect at all!!
Why???
  댓글 수: 2
Jan
Jan 2011년 9월 19일
Perhaps the figure size is set later again? You can use the debugger to find this.
Jan
Jan 2011년 9월 19일
Perhaps the figure size is set later again? You can use the debugger to find this.
MAXFIG fails if the figure is not visible. Therefore I'd use the [0,0,1,1] position in normalized coordinates.

댓글을 달려면 로그인하십시오.


Ocram
Ocram 2011년 9월 19일
I get this if I run the GUI:
java.lang.NullPointerException
at com.mathworks.hg.peer.FigureFrameProxy.setMaximized(FigureFrameProxy.java:208)
at com.mathworks.hg.peer.FigureMediator.setMaximized(FigureMediator.java:451)
at com.mathworks.hg.peer.FigurePeer.doSetMaximized(FigurePeer.java:3311)
at com.mathworks.hg.peer.FigurePeer$26.run(FigurePeer.java:3299)
at com.mathworks.hg.util.HGPeerQueue$HGPeerRunnablesRunner.runit(HGPeerQueue.java:228)
at com.mathworks.hg.util.HGPeerQueue$HGPeerRunnablesRunner.runNotThese(HGPeerQueue.java:260)
at com.mathworks.hg.util.HGPeerQueue$HGPeerRunnablesRunner.run(HGPeerQueue.java:276)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
s =
Normal
  댓글 수: 1
Jan
Jan 2011년 9월 19일
This error appears, if you want to maximize a figure with disabled visibility.

댓글을 달려면 로그인하십시오.


Ocram
Ocram 2011년 9월 19일
And the Opening Fnc is simply this:
% --- Executes just before GUI_prova is made visible.
function GUI_prova_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to GUI_prova (see VARARGIN)
% Choose default command line output for GUI_prova
handles.output = hObject;
maxfig(handles.figure1,1) % maximizes the figure window for the figure with handle F
s = figstate(handles.figure1) % returns the state of figure { Maximized | Minimized | Normal }
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI_prova wait for user response (see UIRESUME)
% uiwait(handles.figure1);

Aurelien Queffurust
Aurelien Queffurust 2011년 9월 19일
As Yair suggests in his comment June 7, 2011 at 1:47 am try to put the maxfig call in the outputfcn intead of opening fcn
  댓글 수: 2
Ocram
Ocram 2011년 9월 19일
Thanks!! Now it works!!!
Ocram
Ocram 2011년 9월 24일
If I put it in the outputfcn is ok!
But I need to maximise the figure before the outputfcn, because I need to use uiwait(handles.figure1) in the openingfcn.
Thanks

댓글을 달려면 로그인하십시오.


Ocram
Ocram 2011년 9월 24일
Do you have any idea? I mean using these 2 lines of code:
maxfig(handles.figure1,1) % maximizes the figure window for the figure with handle F
s = figstate(handles.figure1) % returns the state of figure { Maximized | Minimized | Normal }
  댓글 수: 1
Image Analyst
Image Analyst 2011년 9월 24일
Any idea about what? What about those two lines???

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by