简体   繁体   中英

Customize Look and feel Nimbus

How can I customize the images of the components in the Nimbus Look and Feel? I would like to create the images in photoshop and place on some Nimbus Look and Feel components, these are the components that I want to change:

ScrollBar Button Knob ScrollBar Thumb ScrollBar ScrollBar Track

Thanks!

The best resource for nimbus is the Oracle website itself here . However it mostly outlines customizing the theme via the api and allows customisation of components outwith your program via xml in a somewhat restricted way, to quote another post here

For accessing and modifying the elements you reference this is a useful resource here you can then call the ui manager to apply any modifications you wish in a way such as this:

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

Again there is a useful link here that goes into more detail.about applying colours etc to your ui.

There is also lengthy posts here about using images to modify the themes, but Imo your best bet would be to follow this guide which outlines the xml format for plaf.synth which allows loading of xml purely for customizable themes so pretty much ideal for someone who is using 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"/>

and get the resource with your theme:

 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();
            }

    }

A full sample is available here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM