Open UIGETFILE on 2nd monitor

6 ビュー (過去 30 日間)
Jan
Jan 2012 年 3 月 9 日
編集済み: Jan 2017 年 11 月 13 日
How can I open a uisetfile or uigetfile dialog on a 2nd monitor?
Unfortunately I assume the answer will depend on the Matlab release.
[EDITED]: A meta-message in this question:
The source codes of uigetfile are shipped with Matlab, but they are not useful to change feature of the dialog. In opposite to this, the source code of cellfun is not included in modern Matlab versions anymore. What a pity.

採用された回答

Jette
Jette 2012 年 3 月 20 日
I (still) don't have an answer to this question - but possibly a hint which helps to create your own function:
I just managed to create my own replacement for uigetdir which is based on the Java JFileChooser. I used the answer of <http://stackoverflow.com/questions/6349410/using-uigetfile-instead-of-uigetdir-to-get-directories-in-matlab> as a starting point and found out that replacing
status = jchooser.showOpenDialog([]);
with
javaFrame = get(h_figure,'JavaFrame');
jfig = javaFrame.fFigureClient.getWindow;
status = jchooser.showOpenDialog(jfig);
opens the dialog in the center of h_figure. You cannot choose the exact position - but if you have a figure on the 2nd monitor also the dialog will show up there.
Obviously, this solution depends on the undocumented 'JavaFrame' property. I think you are aware of the consequences.
JFilesChooser can also be used with the option FILES_ONLY to choose files. There is also an option which decides if one or multiple files can be chosen. However, I have not managed yet to specify a FilterSpec to filter for certain extensions.
I have tried JFileChooser for R2010b under Windows XP and Windows 7. With Windows 7, I found that there is a (known) bug such that some buttons are not visible as they should. However, these features are also available via a context menu.
  1 件のコメント
Jan
Jan 2012 年 3 月 26 日
This is the best available solution. Beside the known weakness of UITAB, UITABLE and UITREE, even the standard file choosing dialogs have a noticable potential for improvements.

サインインしてコメントする。

その他の回答 (1 件)

Dr. Seis
Dr. Seis 2012 年 3 月 20 日
Here are some comments within uigetputfile_helper.m that suggest user defined locations are no longer supported in later releases.
% First, check to see if the user entered in two integers as the last two
% arguments. If so, they entered in the obsoleted 'x' and 'y' location
% parameters, which will be ignored. Warn the user, but since this is
% not a fatal error, trim these arguments off and continue.
% Next, see if there are any property-value pairs. The only
% properties allowed are 'MultiSelection' and 'Location'.
% 'Location' is being obsoleted; we will warn the user and ignore
% the value. Trim off the property-value pairs so we are left with
% just convenience arguments.
Looks like in older releases you could just put in a pair of coordinates... but no longer. Oh well.
  1 件のコメント
Jan
Jan 2012 年 3 月 20 日
Ignoring the old x and y values concern the times before the dialogs have been implemented in Java.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by