Set a new external Java look and feel, programmatic GUI

4 ビュー (過去 30 日間)
Luca Di Leta
Luca Di Leta 2016 年 3 月 29 日
コメント済み: Luca Di Leta 2016 年 4 月 1 日
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

回答 (1 件)

Image Analyst
Image Analyst 2016 年 3 月 29 日
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 件のコメント
Image Analyst
Image Analyst 2016 年 3 月 31 日
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
Luca Di Leta 2016 年 4 月 1 日
thank you anyway Image, I will try with Yair

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by