Java Jwindow not showing like before

3 vues (au cours des 30 derniers jours)
AbioEngineer
AbioEngineer le 7 Jan 2021
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

Réponse acceptée

AbioEngineer
AbioEngineer le 8 Jan 2021
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

Plus de réponses (0)

Catégories

En savoir plus sur Call Java from MATLAB dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by