Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5000913

Cannot change icon of radiobutton in synth using state

XMLWordPrintable

    • beta2
    • generic, x86
    • generic, windows_xp



      Name: wm7046 Date: 02/23/2004


      In the synth look and feel in Tiger beta, you should be able to change the icon of JRadioButtons by changing the RadioButton.icon property depending on the state. In my synth xml file, I have:

      <?xml version='1.0' encoding='windows-1252'?>

      <synth version="1">

        <style id="radioButton" >
          <imageIcon id="icon-rb-normal" path="images/blaf-radiobutton.png"/>
          <property key="RadioButton.icon" value="icon-rb-normal" />

          <state value="SELECTED">
            <imageIcon id="icon-rb-selected" path="images/blaf-radiobutton-selected.png"/>
            <property key="RadioButton.icon" value="icon-rb-selected"/>
          </state>
        </style>

        <bind style="radioButton" type="region" key="radioButton" />

      </synth>

      However, at runtime, the radio button's icon does not change depending on its selected state. Instead, it always has the same icon (whichever one I set using <property> last in the .xml file: blaf-radiobutton-selected.png in the above testcase).

      I hope I'm just doing something dumb rather than this being a bug, because sadly synth isn't usable without the ability to do this :(

      Java version:

      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)
      (Incident Review ID: 237288)
      ======================================================================

      Another e-mail on this issue:
      Using J2SE JDK 1.5.0 beta 1 and trying to put different images for
      selected/unselected states of a RadioButton, I came with the following:

      <?xml version='1.0' encoding='windows-1252'?>

      <synth version="1">

        <style id="radioButton" >
          <imageIcon id="unselected" path="images/unselected.png"/>
          <property key="RadioButton.icon" value="unselected" />

          <state value="SELECTED">
            <imageIcon id="selected" path="images/selected.png"/>
            <property key="RadioButton.icon" value="selected"/>
          </state>
        </style>

        <bind style="radioButton" type="region" key="radioButton" />

      </synth>

      However RadioButtons remains with with "selected.png".

      I looked closely at the SynthRadioButtonUI. It seems the "icon" of the
      button is cached in "getDefaultIcon". The "icon" attribute is reset to
      null when "updateStyle" is called. "updateStyle" is called by the
      property change listener added in SynthButtonUI but only if
      "shouldUpdateStyle" returns true. However "shouldUpdateStyle" returns
      true only if "name" or "ancestor" properties change. Maybe the
      "shouldUpdateStyle" should be a protected method of the SynthButtonUI.

      I hope I'm doing something wrong here.

      ###@###.### 2004-02-24

            alexp Alexander Potochkin (Inactive)
            mmma Marvin Ma (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: