有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Synth外观和感觉什么都不做?

我正在尝试实现Synth外观,但它对实际软件的外观没有任何影响。我的文件路径是正确的,因为我已经检查过了。有人知道为什么这不起作用吗:

爪哇:

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:

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

提前谢谢


共 (1) 个答案

  1. # 1 楼答案

    加载外观和感觉的推荐方式是:

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

    source

    您的问题似乎是加载xml资源的方式

    因此,请阅读获取流here的区别

    另外,请仔细查看tutorial