【问题标题】:How do I embed a custom graphic into a border of a panel using Synth?如何使用 Synth 将自定义图形嵌入到面板的边框中?
【发布时间】:2012-04-19 20:22:47
【问题描述】:

我正在学习使用 Synth,并试图弄清楚如何嵌入自定义 png 以用作面板的边框。

我的border.xml 看起来像这样:

<synth>  
<style id="PanelStyle">  
<insets top="15" left="20" right="20" bottom="15"/>  
    <state>  
        <imagePainter method="panelBorder" path="test.png" sourceInsets="10 10 10 10" />  
    </state>  
</style>  
<bind style="PanelStyle" type="region" key="Panel" />  
</synth>  

但是,当我使用该 xml 设置 l&f 时,它会用 png 而不仅仅是边缘填充整个面板。

【问题讨论】:

    标签: java user-interface synth


    【解决方案1】:

    您需要将您的图像画家的paintCenter选项设置为false,如下所示:

    <imagePainter method="panelBorder" paintCenter="false" path="test.png" sourceInsets="10 10 10 10" />
    

    希望这会有所帮助。这是我发现的网站的链接,非常有用:

    http://docs.oracle.com/javase/7/docs/api/javax/swing/plaf/synth/doc-files/synthFileFormat.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-03
      • 1970-01-01
      相关资源
      最近更新 更多