Set a new external Java look and feel, programmatic GUI
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (1)
Image Analyst
am 29 Mär. 2016
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 Kommentare
Image Analyst
am 31 Mär. 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.
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!