简体   繁体   English

Synth Look and Feel什么也没做?

[英]Synth Look and Feel not doing anything?

I am trying to implement the Synth look and feel and it is not doing anything to the look of the actual software. 我正在尝试实现Synth的外观,并且对实际软件的外观没有任何作用。 My file path is correct as I have checked that. 经检查,我的文件路径正确。 Does anybody know why this is not working: 有人知道为什么这不起作用吗?

Java: Java的:

try {
    SynthLookAndFeel laf = new SynthLookAndFeel();
    laf.load(new FileInputStream("src/look_and_feel.xml"), Truss.class);
    UIManager.setLookAndFeel(laf);
} catch (Exception e) {         
    e.printStackTrace();
}

XML: XML:

<synth>
    <style id="default">
        <font name="Courier" size="14" />
    </style>
    <bind style="default" type="region" key="Button" />
</synth> 

Thanks in advance. 提前致谢。

The recommended way of loading the Look-And-Feel is: 建议的加载外观的方法是:

SynthLookAndFeel laf = new SynthLookAndFeel();
laf.load(Truss.class.getResourceAsStream("laf.xml"), Truss.class);
UIManager.setLookAndFeel(laf);

source 资源

Your problem seems to be the way of loading your xml-resource. 您的问题似乎是加载xml资源的方式。

Therefore read about the difference of getting the streams here 因此,请阅读此处获取流的区别

Additionally take a closer look at the tutorial 此外,请仔细阅读教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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