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

Can't enter text in TextField if open Frame before dispose of modal Dialog

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P5 P5
    • None
    • 5.0
    • client-libs
    • None
    • sparc
    • solaris_8

      The test code below pops up a modal dialog; click Ok and it opens a frame with a TextField. Under solaris java 1.5 rc (-b63) I'm unable to enter text in the TextField until I remove focus from the frame and come back. I use Gnome 2.0 with pointer-focus so this means I simply move the mouse off the frame and back over it. I don't see the probem with any of the following changes:
      - Use java 1.4.2
      - Use java 1.5 on windows
      - Use a non-modal dialog
      - Dispose of the modal dialog before opening the new frame
      Obviously I have fixed my own code using the last item listed above.. I'm not sure if this is a bug or just improper usage, but I'm reporting it just in case. The problem is intermittent, but seems to happen most of the time. I'm actually using swing but I wrote my test code with awt for the simplest test case I could find.

      Here is the test code:
      import java.awt.*;
      import java.awt.event.*;

      public class focus implements ActionListener, Runnable
      {
        static Dialog dialog;

        public static void main(String[] args) throws Exception {
          Button b = new Button("Go");
          b.addActionListener(new focus());
          dialog = new Dialog(new Frame(), "dialog", true);
          dialog.add(b);
          dialog.setBounds(10, 10, 200, 100);
          dialog.setVisible(true);
        }

        public void actionPerformed(ActionEvent ev) {
          EventQueue.invokeLater(new focus());
        }

        public void run() {
      // dialog.dispose();
          TextField t = new TextField();
          Frame app = new Frame();
          app.add(t);
          app.setBounds(10, 10, 300, 120);
          app.setVisible(true);
          dialog.dispose();
        }
      }

            art Artem Ananiev (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: