我正在使用Java Swing Synth Look and Feel。我能够指定几个组件的样式。但是,我无法为默认状态设置按钮的字体颜色。按钮文本始终以黑色显示,但在聚焦/选择/移动鼠标时,文本颜色会变为白色,之后会变为黑色。 这是我的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>
我做错了吗?如何更改按钮的默认字体颜色?
其他一些信息:
答案 0 :(得分:1)
似乎我设法解决了这个问题。由于没有明显的原因,我不得不使用颜色tye“FOREGROUND”。
答案 1 :(得分: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" />
此link可能对您有用。