2012-02-11 126 views
1

我想改變我的Matlab GUI使用Java的外觀。繼發現here後的指示,我曾嘗試這樣的代碼:Nimbus的外觀和感覺的Matlab

javax.swing.UIManager.setLookAndFeel('com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel'); 

然而,結果無法正確顯示,我收到以下錯誤信息:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException 
    at com.mathworks.widgets.desk.DTTitleBar$InternalUI.getBottomColor(DTTitleBar.java:1181) 
    at com.mathworks.widgets.desk.DTBorderFactory$DockedFrameBorder.getLineColor(DTBorderFactory.java:370) 
    at com.mathworks.widgets.desk.DTBorderFactory$DockedFrameBorder.paintBorder(DTBorderFactory.java:379) 
    at javax.swing.JComponent.paintBorder(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintToOffscreen(Unknown Source) 
    at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source) 
    at javax.swing.RepaintManager$PaintManager.paint(Unknown Source) 
    at javax.swing.RepaintManager.paint(Unknown Source) 
    at javax.swing.JComponent._paintImmediately(Unknown Source) 
    at javax.swing.JComponent.paintImmediately(Unknown Source) 
    at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) 
    at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) 
    at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source) 
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source) 
    at java.awt.event.InvocationEvent.dispatch(Unknown Source) 
    at java.awt.EventQueue.dispatchEvent(Unknown Source) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.run(Unknown Source) 
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException 
    at com.mathworks.widgets.desk.DTTitleBar$InternalUI.getBottomColor(DTTitleBar.java:1181) 
    at com.mathworks.widgets.desk.DTBorderFactory$DockedFrameBorder.getLineColor(DTBorderFactory.java:370) 
    at com.mathworks.widgets.desk.DTBorderFactory$DockedFrameBorder.paintBorder(DTBorderFactory.java:379) 
    at javax.swing.JComponent.paintBorder(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintToOffscreen(Unknown Source) 
    at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source) 
    at javax.swing.RepaintManager$PaintManager.paint(Unknown Source) 
    at javax.swing.RepaintManager.paint(Unknown Source) 
    at javax.swing.JComponent._paintImmediately(Unknown Source) 
    at javax.swing.JComponent.paintImmediately(Unknown Source) 
    at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) 
    at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) 
    at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source) 
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source) 
    at java.awt.event.InvocationEvent.dispatch(Unknown Source) 
    at java.awt.EventQueue.dispatchEvent(Unknown Source) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.run(Unknown Source) 
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException 
    at com.mathworks.widgets.desk.DTTitleBar$InternalUI.getBottomColor(DTTitleBar.java:1181) 
    at com.mathworks.widgets.desk.DTBorderFactory$DockedFrameBorder.getLineColor(DTBorderFactory.java:370) 
    at com.mathworks.widgets.desk.DTBorderFactory$DockedFrameBorder.paintBorder(DTBorderFactory.java:379) 
    at javax.swing.JComponent.paintBorder(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintChildren(Unknown Source) 
    at javax.swing.JSplitPane.paintChildren(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintChildren(Unknown Source) 
    at javax.swing.JSplitPane.paintChildren(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintChildren(Unknown Source) 
    at javax.swing.JSplitPane.paintChildren(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintChildren(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintChildren(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintChildren(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintChildren(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintChildren(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JLayeredPane.paint(Unknown Source) 
    at javax.swing.JComponent.paintChildren(Unknown Source) 
    at javax.swing.JComponent.paintToOffscreen(Unknown Source) 
    at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source) 
    at javax.swing.RepaintManager$PaintManager.paint(Unknown Source) 
    at javax.swing.RepaintManager.paint(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source) 
    at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source) 
    at sun.awt.SunGraphicsCallback.runComponents(Unknown Source) 
    at java.awt.Container.paint(Unknown Source) 
    at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) 
    at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) 
    at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source) 
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source) 
    at java.awt.event.InvocationEvent.dispatch(Unknown Source) 
    at java.awt.EventQueue.dispatchEvent(Unknown Source) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.run(Unknown Source) 
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException 
    at com.mathworks.widgets.desk.DTTitleBar$InternalUI.getBottomColor(DTTitleBar.java:1181) 
    at com.mathworks.widgets.desk.DTBorderFactory$DockedFrameBorder.getLineColor(DTBorderFactory.java:370) 
    at com.mathworks.widgets.desk.DTBorderFactory$DockedFrameBorder.paintBorder(DTBorderFactory.java:379) 
    at javax.swing.JComponent.paintBorder(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintChildren(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintChildren(Unknown Source) 
    at javax.swing.JComponent.paint(Unknown Source) 
    at javax.swing.JComponent.paintToOffscreen(Unknown Source) 
    at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source) 
    at javax.swing.RepaintManager$PaintManager.paint(Unknown Source) 
    at javax.swing.RepaintManager.paint(Unknown Source) 
    at javax.swing.JComponent._paintImmediately(Unknown Source) 
    at javax.swing.JComponent.paintImmediately(Unknown Source) 
    at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) 
    at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) 
    at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source) 
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source) 
    at java.awt.event.InvocationEvent.dispatch(Unknown Source) 
    at java.awt.EventQueue.dispatchEvent(Unknown Source) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.run(Unknown Source) 

我不明白髮生什麼事。

+0

最有可能的matlab組件被創建爲僅與matlab提供的外觀和感覺一起工作。 – 2012-02-11 14:44:23

+0

感謝您的評論。但是,可以這樣做(請參閱我剛剛添加的鏈接)。 – julian 2012-02-11 14:57:34

+2

根據Muhammad Abrar的說法,我會推薦在出現Matlab GUI之前設置Look and Feel。 Matlab有一些很好的初始化模式,只是在gui加載之前把代碼改成L&F,它將消除初始化問題。 – 2012-02-11 15:07:10

回答

2

閱讀您提供的鏈接的評論部分。引用:

更改爲L &˚F確實對Java異常被拋出 問題。若要更改整個桌面,設置爲L &˚F然後調用:

f=com.mathworks.mde.desk.MLDesktop.getInstance.getMainFrame(); 
javax.swing.SwingUtilities.updateComponentTreeUI(f); 

我嘗試過,但只是一些部分被改變,而GUI變得相當不可用。我在Linux上運行Matlab 2010。

+0

非常感謝您的回答。下次我會更安靜地閱讀這些信息。 – julian 2012-02-11 16:10:43