I am trying to obtain simple flat button using synth xml in Java. This button should contain solid color background and text with no other effects.
I have checked some tutorials and successfully implemented below solution where I will need to provide the solid color background image for the button.
<state>
<imagePainter method="buttonBackground" path="images/button_press.png" sourceInsets="10 10 10 10"/>
<font name="Dialog" size="16"/>
<color type="TEXT_FOREGROUND" value="#FFFFFF"/>
</state>
But as per synth documentation here I should be able to provide the Background color to the button instead of using an image. I have tried below XML settings for the same. But it is not applying any background to buttons. Whereas it is applying provided color to text.
<state>
<font name="Verdana" size="14"/>
<color value="#FF0000" type="BACKGROUND"/>
<color value="#000000" type="TEXT_FOREGROUND"/>
</state>
Can anyone check and help me find out the mistake I have done or there is any other solution for this?
I guess you would need to use
<opaque value="true" />
to paint theJButton
's background:button.xml
SynthButtonTest.java