簡體   English   中英

自定義外觀和感覺

[英]Customize Look and feel Nimbus

如何在Nimbus外觀中自定義組件的圖像? 我想在photoshop中創建圖像,並將其放置在某些Nimbus Look and Feel組件上,這些是我要更改的組件:

ScrollBar按鈕旋鈕ScrollBar拇指ScrollBar ScrollBar軌道

謝謝!

對於靈氣的最佳資源是Oracle網站本身在這里 但是,它主要概述了通過api自定義主題,並允許通過xml以某種受限的方式通過程序自定義組件,請在此處引用另一篇文章

為了訪問和修改您引用的元素,這是一個有用的資源您可以在此處調用ui管理器以如下方式應用您希望的任何修改:

UIManager.put("nimbusBase", new Color(...)); UIManager.put("nimbusBlueGrey", new Color(...)); UIManager.put("control", new Color(..

再有一個有用的鏈接這里是進入更多的應用detail.about顏色等,以你的用戶界面。

還有漫長的帖子在這里關於使用圖像修改的主題,但伊莫你最好的選擇將遵循本指南,概述了XML格式plaf.synth這使得XML的裝載純粹是定制的主題,所以非常理想的人誰正在使用photoshop:

<style id="buttonStyle">
   <insets top="15" left="20" right="20" bottom="15"/>
   <state>
      <imagePainter method="buttonBackground" path="images/button.png"
        sourceInsets="10 10 10 10"/>
   </state>
</style>
<bind style="buttonStyle" type="region" key="button"/>

並獲取與您的主題相關的資源:

 private static String synthFile = "buttonSkin.xml";
 private static void initLookAndFeel() {
       // String lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
       SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();


            try {
                lookAndFeel.load(SynthApplication.class.getResourceAsStream(synthFile),
                                  SynthApplication.class);
                UIManager.setLookAndFeel(lookAndFeel);
            } 

            catch (Exception e) {
                System.err.println("Couldn't get specified look and feel ("
                                   + lookAndFeel
                                   + "), for some reason.");
                System.err.println("Using the default look and feel.");
                e.printStackTrace();
            }

    }

完整樣本在這里

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM