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

fp.bugs 2955 unnecessary call to Frame.show() crashes solaris.

XMLWordPrintable

    • sparc
    • solaris_2.4

      ###@###.### (Robert Uomini)
      Solaris only: extra call to Frame.show() causes crash

      Steps to reproduce:
      Compile and run the attached code
      Select Main Menu | Item 1
      Select any item in the list.
      // note: crash


      import java.awt.*;
      import java.util.*;

      public class BugReport2 extends Frame
      {
          public MenuBar main_mbar;

          public List group_list;
          public List selected_groups_list;

          public Panel main_panel;
          public Panel newgroups_panel;

          public int windowWidth = 100;
          public int windowHeight = 200;

          Button done_button;

          ViewgrpMenu viewgrpMenu;

          TextArea main_canvas;

          int currline = 0;
          private final String groups[] =
          {
             "Item #1.........................................................................................................................................................................",
             "Item #2.........................................................................................................................................................................",
             "Item #3.........................................................................................................................................................................",
             "Item #4.........................................................................................................................................................................",
             "Item #5.........................................................................................................................................................................",
             "Item #6.........................................................................................................................................................................",
             "Item #7.........................................................................................................................................................................",
             "Item #8.........................................................................................................................................................................",
             "Item #9..........................................................................................................................................................................",
             "Item #10.........................................................................................................................................................................",
             "Item #11........................................................................................................................................................................."
          };

          public BugReport2(String args[])
          {
             super("Bug Report");

             main_panel = new Panel();

             create_main_menu();

             group_list = new List(10, false);
             add("North", group_list);

             selected_groups_list = new List(10, false);
             for (int i = 0; i < groups.length; ++i)
                selected_groups_list.addItem(groups[i]);


             main_canvas = new TextArea(30, 80);
             add("Center", main_canvas);

             setMenuBar(main_mbar); // install this menu bar in the frame

             add("South", main_panel);

             newgroups_panel = new Panel();
             done_button = new Button("Done");
             newgroups_panel.add(done_button);

             group_list.select(0);
             resize(windowWidth, windowHeight);
             pack();
             show();
          }

          public boolean handleEvent(Event evt)
          {
             String article_str;
             String data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";

             switch (evt.id)
             {
                case Event.LIST_SELECT:
                   article_str = new String(data + "\\n");
                   for (int index = 0; index < 60;
                      article_str += data + data + data + "\\n", index++);
                   main_canvas.replaceText("", 0, currline);
                   currline = article_str.length();
                   main_canvas.insertText(article_str, 0);
                   replace_marker( selected_groups_list.getSelectedItem(),
                                   "item selected" );
                   pack();

                   // extra call to show() causes crash
                   show();
                   return true;
                default:
                   return super.handleEvent(evt);
             }
          }

          public void show_main_screen(Panel panel, List list)
          {
             remove(panel);
             remove(list);
             add("North", group_list);
             add("South", main_panel);
             // setMenuBar(main_mbar);
             main_canvas.setText("");
             resize(windowWidth, windowHeight);
             pack();
             show();
          }

        public boolean action(Event evt, Object arg)
          {
          if (evt.id == Event.ACTION_EVENT)
            {
            if ("Done".equals(evt.arg))
      {
      show_main_screen(newgroups_panel, selected_groups_list);
      return true;
      }
            if ("Item 1".equals(evt.arg))
      {
      remove(main_panel);
      remove(main_mbar);
      add("North", selected_groups_list);
      add("South", newgroups_panel);
      pack();
      show();
      return true;
      }
            }
          return true;
          }

        public void create_main_menu()
          {
          main_mbar = new MenuBar();
          viewgrpMenu = new ViewgrpMenu("Demo Menu");
          main_mbar.add(viewgrpMenu);
          }

        public void replace_marker(String text, String marker)
          {
          String tmp_string;

          int marker_loc;

          if ((marker_loc = text.indexOf(marker)) == -1)
            {
            tmp_string = new String(text.substring(0, Math.min(text.length(), 180)));
            for(; tmp_string.length() < 181; tmp_string += " ");
            tmp_string += marker;
            selected_groups_list.replaceItem(tmp_string,
      selected_groups_list.getSelectedIndex());
            }
          }

        public static void main(String args[])
          {
          new BugReport2(args);
          }
        }


            amfowler Anne Fowler (Inactive)
            kasmithsunw Kevin Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: