Set a new external Java look and feel, programmatic GUI
Mostra commenti meno recenti
Hi guys!
I’m Luca an Italian mechanical engineer. These days I have tried to add the JTattoo look and feel in Matlab programmatic GUI R2015b but I have failed. I’m not an expertise of Java and I have tried your instructions on http://undocumentedmatlab.com/blog/modifying-matlab-look-and-feel without success.
---------------------------------------------------------------------
% A simple GUI script
function TestGUI ()
fig= figure ;
% Add the JTatto java library
folder = fileparts(mfilename('fullpath'));
javaclasspath( {folder, [folder '\JTattoo.jar']} );
newLnF = 'com.jgoodies.looks.plastic.Plastic3DLookAndFeel'; %string
javax.swing.UIManager.setLookAndFeel(newLnF);
jbutton = javax.swing.JButton('Java Button');
function placeJavaComponent ( jcomponent, position, parent )
jcomponent = javaObjectEDT( jcomponent ); % ensure component is auto-delegated to EDT
jcomponent.setOpaque(false); % useful to demonstrate L&F backgrounds
[jc,hContainer] = javacomponent( jcomponent, [], parent ); %#ok<ASGLU>
set(hContainer, 'Units','Normalized', 'Position',position);
end % placeJavaComponent
placeJavaComponent(jbutton,[0.1 0.8 0.8 0.07],fig );
drawnow;
originalLnF = javax.swing.UIManager.getLookAndFeel;
% Restore original L&F for other GUI
javax.swing.UIManager.setLookAndFeel(originalLnF)
end
---------------------------------------------------------------------
the above matlab script run without problem but if I set a JTattoo look and feel, for example
newLnF = 'com.jtattoo.plaf.smart.SmartLookAndFeel'; %string
javax.swing.UIManager.setLookAndFeel(newLnF)
I get this error:
---------------------------------------------------------------------------------------------------
Java exception occurred:
java.lang.ClassNotFoundException: com.jtattoo.plaf.smart.SmartLookAndFeel
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at javax.swing.SwingUtilities.loadSystemClass(Unknown Source)
at javax.swing.UIManager.setLookAndFeel(Unknown Source)
---------------------------------------------------------------------------------------------------
Surely Matlab have no idea where the selected look and feel are saved, and cannot point to it even if the JAR file is in the correct folder. Could you explain me how to solve this problem, It’s surely a trivial problem but don’t know how to solve it, I would appreciate very much.
Many thanks in advance
Luca Di Leta
Risposte (1)
Image Analyst
il 29 Mar 2016
0 voti
I haven't tried it personally yet, but maybe you'd like to try the new App Designer user interface builder tool: http://www.mathworks.com/products/matlab/app-designer/
5 Commenti
Luca Di Leta
il 29 Mar 2016
Modificato: Luca Di Leta
il 29 Mar 2016
Image Analyst
il 29 Mar 2016
Modificato: Image Analyst
il 29 Mar 2016
I believe it will work with R2015b. I know for a fact it works with R2016a because that's what I have. Type appdesigner on the command line and see if it comes up.
If you want undocumented ways of using Java, the place to go is Yair Altman's outstanding MATLAB site http://undocumentedmatlab.com/
Luca Di Leta
il 31 Mar 2016
Modificato: Luca Di Leta
il 31 Mar 2016
Image Analyst
il 31 Mar 2016
I'm not an expert in java and in using special java code in MATLAB. But Yair is, so that's why I referred you to him. Sorry, but good luck.
Luca Di Leta
il 1 Apr 2016
Categorie
Scopri di più su Environment and Settings in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!