Is there any way to get the uigetfile panel to be centered in the monitor when it first comes up????

8 views (last 30 days)
I use the MATLAB function uigetfile to read in the path and name of a file. How do I get that panel to appear in the center of the screen. It always pops up in the upper left corner of the screen.
Note, this code must work with the compiler also.
Thanks Bob
  8 Comments
Walter Roberson
Walter Roberson on 17 Mar 2022
Having the functionality work sometime is better than not having it work at all.
However, as you are working with Windows, do not be astonished if it suddenly stops working with some KB*, or if it works differently depending which Creators Edition or half-year Windows update, or whatever.
Matt J
Matt J on 17 Mar 2022
Edited: Matt J on 17 Mar 2022
So for now, "Operating-System Dependent Behavior" is best for me. It works.
I'm on a Windows 10 OS and, as I said, the method doesn't work on my machine. I think you will see that if you manually drag the uigetfile window to some random location on the screen and then re-run your code. In Windows, the uigetfile windows will always open where it was last positioned.

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 15 Mar 2022
No, there is no control over that.
If you are not using a deployed app, then MATLAB runs a java method to start an operating-system native file picker. There are no user-level controls over where that operating-system facility will appear.

Matt J
Matt J on 15 Mar 2022
If you drag the uigetfile window to the location where you want it then, the next time you call uigetfile, it will open in that position, even if it's in a later Matlab session. I don't know if something similar would hold true for a deployed app.

Categories

Find more on Dialog Boxes in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!