Setting the background image of a JToggleButton

459 views Asked by At

I am trying to use synth look and feel xml to set the background image of a JToggleButton which seems to work but the text in the button isn't displaying. Is there something that I'm missing? Here's the code:

laf.xml:

<style id="dayBtnStyle">
    <insets top="4" left="18" right="18" bottom="3"/>
    <state>
      <font name="HelveticaNeue" size="40"/>
      <color value="#586A7B" type="TEXT_FOREGROUND"/>
      <imagePainter path="images/keyDay-Off.png"
                    sourceInsets="10 10 10 10"/>
    </state>
    <state value="SELECTED">
      <font name="HelveticaNeue" size="40"/>
      <color value="WHITE" type="TEXT_FOREGROUND"/>
      <imagePainter method="buttonBackground" path="images/keyDay-On.png"
                    sourceInsets="10 10 10 10"/>
    </state>
  </style>
  <bind style="dayBtnStyle" type="name" key="dayBtn"/>

test.java:

  JToggleButton b = new JToggleButton ("test");
            b.setName("dayBtn");
0

There are 0 answers