Java Jwindow not showing like before

2 ビュー (過去 30 日間)
AbioEngineer
AbioEngineer 2021 年 1 月 7 日
回答済み: AbioEngineer 2021 年 1 月 8 日
The JWindow object is not able to show anymore. I'm using a transparent jwindow to house a gif as a loading screen for my app, but the window does not show. Manually running the code in the command window of r2020b isn't working like it did for r2019a. Can anyone please run this below code with an image you have laying around and see if you can get it to display? I just updated to r2020b and now it doesn't work for me.
win = javax.swing.JWindow;
win.setBackground(java.awt.Color(0,0,0,0));
html=strcat('<html><img src="file:./',YOUR IMAGE HERE,'"/></html>');
label = javax.swing.JLabel(html);
win.getContentPane.add(label);
win.setAlwaysOnTop(true);
win.pack;
%% set the splash image to the center of the screen
screenSize = win.getToolkit.getScreenSize;
screenHeight = screenSize.height;
screenWidth = screenSize.width;
% set Location
win.setLocation((screenWidth-500)/2,(screenHeight-500)/2);
win.show

採用された回答

AbioEngineer
AbioEngineer 2021 年 1 月 8 日
Sorry to answer my own question. Just thought I'd share that JLabel no longer scales itself to fit the image dimensions. In short, just replace the html line with
html=sprintf('<html><img src="file:./%s" width="%d" height="%d">', filename, imageWidth, imageHeight);
Obviously, replace these variable names or assign them values. You can also use java's bufferedimage class with the method getWidth() and getHeight() to find these dimensions

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by