2012-07-24 71 views
1

我無法弄清楚如何更改構建在NetBeans平臺框架上的應用程序的LookAndFeel,有誰可以請幫忙嗎?我想用TinyLAF java api http://www.muntjak.de/hans/java/tinylaf/index.html來改變它的外觀。在NetBeans IDE中開發常規Swing應用程序時,我知道如何更改LookAndFeel,但在NetBeans平臺框架上開發時無法更改LookAndFeel。如何更改NetBeans平臺框架應用程序的LookAndFeel

這是代碼,TinyLAF,我使用的常規Swing應用程序:

Toolkit.getDefaultToolkit().setDynamicLayout(true); 
System.setProperty("sun.awt.noerasebackground", "true"); 
JFrame.setDefaultLookAndFeelDecorated(true); 
JDialog.setDefaultLookAndFeelDecorated(true); 

try { 
    UIManager.setLookAndFeel("de.muntjak.tinylookandfeel.TinyLookAndFeel"); 
} catch(Exception ex) { 
    ex.printStackTrace(); 
} 

TinyLaF查找名爲「Default.theme」(區分大小寫),默認的主題文件。如果它找到一個,這個文件將在啓動時加載。 ('Default.theme'文件是一個普通的TinyLaF .theme文件,只是一個特殊的名字,你可以帶任何.theme文件並將其重命名爲'Default.theme')。

TinyLaF將搜索以下URL:

  1. TinyLookAndFeel.class.getResource( 「/ Default.theme」);
    • 認定 'Default.theme' 如果是內部tinylaf.jar
  2. Thread.currentThread()getContextClassLoader()的getResource( 「Default.theme」)。。
    • 認定 'Default.theme' 如果這是你的應用程序的JAR
  3. 新文件(System.getProperty( 「的user.home」), 「Default.theme」)。toURI()的toURL內( );
    • 認定 'Default.theme' 如果它是主目錄
  4. 新文件(System.getProperty( 「user.dir來」), 「Default.theme」)。toURI()的toURL內( );
    • 認定「Default.theme」如果是工作目錄內

請注意,我的問題不是如何更改NetBeans IDE的LookAndFeel的,但如何做到這一點的Java應用程序構建在NetBeans平臺框架之上。

回答

2

我發現下面的搜索網:你需要做的模塊「安裝程序」的。 檢查此鏈接,你需要在哪裏添加:http://joshiegeek.blogspot.co.il/2012/01/netbeans-platform-custom-laf.html

這其中有實際的代碼示例(請忽略標題:)):http://forums.netbeans.org/topic39450.html

終於特定PLAF的這一個會談,但沿着有幾點意見的方式:https://blogs.oracle.com/geertjan/entry/blue_look_and_feel_for

+0

非常感謝。解決方案在第一個環節。 – jadrijan 2012-07-24 20:01:25

+0

不客氣。快樂它得到了解決:) – 2012-07-24 20:20:13

+0

第一個鏈接已經死了。我希望你已經告訴了更多關於它曾經說過的話...... – 2014-01-30 18:27:42

1

你可以非常容易地改變揮杆的外觀和風格,其基於MVC架構

2.搖擺也被稱爲PLAF(插入外觀),所以保持相同型號的部分,改變視圖,例如像桌面和Web應用程序相同的模型。

3。使用

UIManager.setLookAndFeel(Your_Choice_of_Look_and_Feel); // To set the Look and Feel 
SwingUtilities.updateComponentTreeUI(frame);  // To refresh the JFrame and Components 

有關詳細信息,請參閱本:

http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

+0

OP已經知道這一點我猜,他提到了他用於常規擺動應用程序的代碼。他想知道如何在Netbeans平臺上運行應用程序。 – 2012-07-24 18:48:00

+0

他需要在GUI代碼中手動更改它,正如我上面提到的...我希望他使用的是NetBeans團隊在2005年開發的GroupLayout,這將使安排組件更容易 – 2012-07-24 18:49:47

相關問題