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

retitling checkboxes does not work

    XMLWordPrintable

Details

    • 1.0.2
    • sparc
    • solaris_2.4
    • Verified

    Description

      (The description field of this report went missing when I first submitted it.)

      Compile and run the following program:

      --------
      import java.applet.*;
      import java.awt.*;

      public class test extends Applet
      {
         public static void main(String args[])
         {
            Frame f = new Frame("Test");
            test t = new test();

            t.init();
            t.start();

            f.resize(100, 100);
            f.add("Center", t);
            f.show();
         }

         public void init()
         {
            setLayout(new BorderLayout());
            add("Center", new Test());
         }
      }

      class Test extends Panel
      {
         Checkbox box = new Checkbox("i am happy");
         
         public Test()
         {
            setLayout(new BorderLayout());
            add("Center", box);
         }

         public boolean action(Event evt, Object obj)
         {
            if (evt.target instanceof Checkbox)
            {
      Checkbox box = (Checkbox) evt.target;

      if (box.getState())
      {
      box.setLabel("happy i am");
      } else {
      box.setLabel("sad = 1");
      }
            }
            return true;
         }
      }
      --------

      When the checkbox is pressed, X (probably Motif) complains with:

      Warning:
          Name: i am happy
          Class: XmToggleButton
          Invalid XmNlabelString - must be a compound string

      The description field as copied from bug report 1234619 follows:


      When a checkbox is added to an applet and then its label is changed using setLabel()
      it generates a warning (and infact the label remains unchanged).

      Here is the result of executing CheckboxTest2.java from the AWT test suite.

      [284] [awt] ? appletviewer CheckboxTest2.html
      thread applet-CheckboxTest2.class find class CheckboxTest2
      Opening stream to: file:/home/vijay/jdk-ws/src/share/test/awt/CheckboxTest2.class to get CheckboxTest2
      Warning:
          Name: WrongLabel1
          Class: XmToggleButton
          Invalid XmNlabelString - must be a compound string

      Warning:
          Name: WrongLabel1
          Class: XmToggleButton
          Invalid XmNlabelString - must be a compound string
      ^C

      However if the buttons are added to a panel which is then added to the applet,
      and then its label is changed, the motif warning doesnt appear and the label change
      works fine.

      Vijay

      Attachments

        Issue Links

          Activity

            People

              amfowler Anne Fowler (Inactive)
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: