0

我正在使用 Java Swing Synth 外观。我可以指定几个组件的样式。尽管如此,我无法将按钮的字体颜色设置为默认状态。按钮的文本始终显示为黑色,但是当聚焦/选择/将鼠标移到文本上时,颜色变为白色,然后又变为黑色。这是我的合成 XML 文件的片段:

<synth>
<style id="defaultStyle">
    <font name="Dialog" size="16" />
</style>
<bind style="defaultStyle" type="region" key=".*" />
<style id="button">
   <property key="Button.textShiftOffset" type="integer" value="1"/>
   <state>
      <imagePainter method="buttonBackground" path="./images/JButton/default.png"
           sourceInsets="20 24 20 24" paintCenter="true" stretch="true"/>
      <insets top="20" left="24" bottom="20" right="24"/>
      <color type="TEXT_FOREGROUND" value="#FFFFFF"/>
   </state>
</style>
<bind style="button" type="region" key="Button" />
...
</synth>

难道我做错了什么?如何更改按钮的默认字体颜色?

一些附加信息:

  • Java 1.6
  • Windows 7,32 位
4

2 回答 2

1

似乎我设法修复它。不知为何,我不得不使用颜色“FOREGROUND”。

于 2011-06-27T06:12:07.413 回答
0

试试这个

<style id="button">
   <property key="Button.textShiftOffset" type="integer" value="1"/>
   <font name="Dialog" size="12"/>
   <state>
      <imagePainter method="buttonBackground" path="./images/JButton/default.png"
           sourceInsets="20 24 20 24" paintCenter="true" stretch="true"/>
      <insets top="20" left="24" bottom="20" right="24"/>
      <color type="TEXT_FOREGROUND" value="#FFFFFF"/>
   </state>
</style>
<bind style="button" type="region" key="Button" />

链接可能对您有用。

于 2013-07-01T07:20:15.190 回答