Can Matlab deploytool compile files with javax.swing elements?

Suppose I have a set of codes for displaying JFrame, JPanel, and JLabel. This works fine if I run it as a script file. It just shows a tiny window with a label that says “Shortcut,” as you would expect:

frame = javax.swing.JFrame('Test');
panel = javax.swing.JPanel();
label = javax.swing.JLabel('A label');
panel.add(label);
frame.add(panel);
frame.setDefaultCloseOperation(javax.swing.JFrame.HIDE_ON_CLOSE);
frame.pack();
frame.setVisible(true);

The problem occurs when I compile it as an exe file using deploytool. It will compile, and I can run the program, but the frame will be displayed for about 3 seconds or so, and then disappear. If I run from inside Matlab with! Main.exe, the error message does not disappear (I do not want to say that it crashes because the error message is missing). Also, no, if I ran the executable from the Windows command line (the same results are displayed for a few seconds, and then fail).

Any ideas what is going on here? I can compile other files just fine. Is the problem that I included javax.swing elements?

Many thanks for your help.

UPDATE

, while, Matlab, JFrame , . , , ?

+4
1

, , M- , , Matlab . Java Swing , , Swing . Matlab, , " " , Matlab, , . ( Matlab , IDE, IDE Matlab, , , .)

" ", MathWorks, - , , Matlab Builder JA, Matlab Java, , Java. , Java "" , " , Java-", , , .

, , . , ; Matlab. , , .

- . , . Java- . java.lang.System.exit(). Matlab, M-, " " Matlab, exit() . , Java Matlab timer, 500 .

, , , Java Swing , . Matlab Java AWT Swing, , . , , Matlab timer, , Java , Matlab, , .

+2

Source: https://habr.com/ru/post/1527802/


All Articles