Set a new external Java look and feel, programmatic GUI
조회 수: 18 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!