setting font color of button using XML and Java Swing Synth LaF
I'm using the Java Swing Synth Look and Feel. I'm able to specify the style of several components. Nonetheless, I'm not able to set the font color of a button for t开发者_开发知识库he default state. Text of buttons is always displayed in black, but when focusing/selecting/moving mouse over text color changes to white and afterwards back to black. Here's a snippet of my synth-XML-file:
<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>
Am I doing something wrong? How can I change the default font color of the button?
Some additional information:
- Java 1.6
- Windows 7, 32-bit
Seems as I managed to fix it. For no known reason I had to use color tye "FOREGROUND".
Try this instead
<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" />
This link might useful for you.
精彩评论