我不知道如何精確地回答你的問題。我所能做的就是展示如何使用不同的UI來運行我的應用程序,請參閱下文。該示例顯示我如何從the Substance library安裝外觀和感覺之一。
public static void main(String[] argv) throws InterruptedException, InvocationTargetException
{
SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
try
{
UIManager.setLookAndFeel(new SubstanceSaharaLookAndFeel());
//Some people say the below should also be called but even without it always worked for me so what is this for then?
//SwingUtilities.updateComponentTreeUI(frame);
}catch(Exception e)
{
Logger.getLogger(MyApplicationFrame.class.getName()).log(Level.SEVERE, null, e);
System.out.println("Substance look and feel failed to initialize");
}
new MyApplicationFrame();
}
});
}
至於在關於調用SwingUtilities.updateComponentTreeUI(frame);
我猜想它在需要的時候你正在改變你的樣子,並在應用程序已經運行感受代碼的註釋。
希望它對你有任何幫助。
**「有人說下面也應該被調用,但是即使沒有,它總是爲我工作,那麼這是什麼?」**當您在可見的GUI上動態更改LAF時,會使用該方法。如果您在創建任何組件之前更改LAF,則無需擔心該組件是使用當前的LAF創建的。 – camickr 2011-05-14 15:07:26
非常感謝@camickr我懷疑這是它的用處。 – Boro 2011-05-14 15:47:51