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

Choice objects fail in modal dialogs (serious bug)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.1.7
    • client-libs
    • x86
    • windows_nt



      Name: diC59631 Date: 10/02/98


      Compile and run the included program. You will
      notice that the scrollbar in java.awt.Choice
      object fails to respond to mouse interaction
      if and only if the Choice object is in a modal
      dialog. Choice works fine in Frames and in
      modeless dialogs.

      In JDK 1.1.6 Choice works fine in all three
      cases, but it fails in modal case in 1.1.7.

      --- Start source code ---
      import java.awt.*;
      import java.awt.event.*;

      public class Test extends Frame
      {
          public static void main(String[] args)
          {
              Frame f = new Test();
              f.setSize(400, 300);
              f.setVisible(true);
          }
          public Test()
          {
              super("Java Test");
              addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) { System.exit(0); }
              });
              setLayout(new GridLayout(4, 1));
              // Choice
              Choice c = new Choice();
              for (int i = 1; i < 20; i++)
                  c.add("Option "+i);
              add(c);
              // Dialog button
              Button btn = new Button("Show Modal");
              btn.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      Dialog d = new TestDialog(Test.this, true);
                      d.setSize(300, 200); d.show();
                  }
              });
              add(btn);
              btn = new Button("Show Modeless");
              btn.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      Dialog d = new TestDialog(Test.this, false);
                      d.setSize(300, 200); d.show();
                  }
              });
              add(btn);
              // Close button
              btn = new Button("Close");
              btn.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) { System.exit(0); }
              });
              add(btn);
          }
      }

      class TestDialog extends Dialog
      {
          TestDialog(Frame parent, boolean modal)
          {
              super(parent, "Testing Choice class", modal);
              setLayout(new GridLayout(2, 1));

              Choice c = new Choice();
              for (int i = 1; i < 20; i++)
                  c.add("Option "+i);
              add(c);
              Button close = new Button("Close");
              add(close);
              close.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      setVisible(false);
                      dispose();
                  }
              });
          }
      }

      --- End source code ---
      (Review ID: 39857)
      ======================================================================

            Unassigned Unassigned
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: