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

Adding an item to a Choice after creation gets wrong (bigger) font.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1
    • 1.1
    • 1.1
    • client-libs
    • 1.1fcs
    • generic
    • solaris_2.5
    • Not verified

    Description

      HotJava has an applet that dynamically changes the contents of a Choice component. Adding an item back after removing it causes the new item to be in a different larger font. I showed Jeff Dinkins this bug in HotJava and talked with him about it.

      This behavior is demonstrated by the following program (also found at ~terryc/hacks/ChoiceBug.java):

      import java.lang.*;
      import java.awt.*;

      public class ChoiceBug extends Frame {
          static String[] list1 = {"Fee", "Fie", "Foe", "Fum"};
          static String[] list2 = {"Fee", "Fie", "Foe"};
          Choice choices;

          public ChoiceBug() {
      init();
          }

          void init() {
      Panel menuBox = new Panel();
      choices = makeChoice(list2);
      menuBox.add(choices);
      add("Center", menuBox);

      Button toggleButton = new Button("Toggle Choices");
      Button quitButton = new Button("Quit");

      Panel buttonBar = new Panel();
      buttonBar.add(toggleButton);
      buttonBar.add(quitButton);

      add("South", buttonBar);
      pack();
          }

          public boolean action(Event event, Object arg) {
      String button = (String)arg;
      if (button.equalsIgnoreCase("Toggle Choices")) {
      if (choices.getItemCount() < list1.length) {
      // add back in
      choices.add(list1[list1.length - 1]);
      }
      else if (choices.getItemCount() > list2.length) {
      // remove last
      choices.remove(list2.length);
      }

      return true;
      }
      else if (button.equalsIgnoreCase("quit")) {
      System.exit(0);
      return true;
      }

      return false;
          }

          public static void main(String[] args) {
      ChoiceBug it = new ChoiceBug();
      it.show();
          }

          Choice makeChoice(String[] items) {
      Choice choices = new Choice();
      for (int i = 0; i < items.length; i++) {
      choices.add(items[i]);
      }

      return choices;
          }
      }

      Attachments

        Activity

          People

            jeff Jeff Dinkins
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: