How do I programmatically set the size of the the web browser window that is created with the MATLAB web command " web " ?

8 ビュー (過去 30 日間)
I would like to use MATLAB's built-in web capabiliies to open a web page and place it on my screen in a specific location.
For example, when I enter the command:
[h1,h2,h3]=web('http://news.google.com','-notoolbar','-new'); % open a web page
I am able to determine the location of the web page on my screen:
webPageScreenInfo = ([h2.getLocationOnScreen.x, ...
h2.getLocationOnScreen.y, ...
h2.getSize.width, ...
h2.getSize.height]);
I have only been able to get the location but not to set the location.
And my available screen size is given by:
availableScreenSize = get( groot, 'Screensize' ); % determine size of my screen
I have played with some undocumented stuff in MATLAB by exploring these commands and a few others:
methodsview('com.mathworks.mde.webbrowser.WebBrowser')
com.mathworks.mlservices.MatlabDesktopServices.getDesktop.closeGroup('Web Browser')
I am lost on how to proceed. Please help!

採用された回答

Yair Altman
Yair Altman 2019 年 1 月 23 日
編集済み: Yair Altman 2019 年 1 月 24 日
Note: undocumented/unsupported:
[h1,h2,h3] = web('http://news.google.com','-notoolbar','-new'); % open a web page
drawnow; pause(0.05);
jWindow = h2.getTopLevelAncestor;
jWindow.setSize(java.awt.Dimension(800,400)); % width,height
jWindow.setLocation(java.awt.Point(300,500)); % x,y
Note that the x,y location is the pixel-position of the window's top-left corner, downward & rightward of the top-left monitor corner (unlike Matlab which measures upward from bottom-left, Java measures downward from top-left).
Yair Altman
  3 件のコメント
Yair Altman
Yair Altman 2019 年 1 月 24 日
You need to let the new window fully render before retrieving its window handle. You do this with a drawnow and/or pause command. I edited my answer above to reflect this. You can modify the pause duration [or perhaps even eliminate the pause altogether) to suit your specific platform.
Yair Altman
Jitender Gangwar
Jitender Gangwar 2020 年 11 月 27 日
How do i change the zoom of the opened window?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by