开发者

setting font color of button using XML and Java Swing Synth LaF

开发者 https://www.devze.com 2023-03-09 23:31 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号