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

requestFocus() does not work with modal Dialog...

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • None
    • 1.1.3
    • client-libs
    • None
    • sparc
    • solaris_2.5.1



      Name: rlT66838 Date: 07/17/97


      I am trying to have focus sent to a TextField
      when a Dialog window is created/shown, but this
      only works if the "window" is either a Frame or
      a Dialog with modal=false. See the following code
      segment:

      public class CLLogin
      {
         public CLLogin(Frame parent)
         {
            super(parent, "Login Screen", true);

            // Set size
            setBounds(400,400,330,175);
            setResizable(false);

            // Set font
            Font font = new Font("Dialog", Font.BOLD, 16);
            setFont(font);

            // Set colors
            setForeground(Color.black);
            setBackground(Color.lightGray);

            addComponents();

            show();
            addWindowListener(new WindowAdapter()
            {

               public void windowActivated(WindowEvent event)
               {
                  userNameText.requestFocus();
               }
            });
         }
      }

      Where addComponents() adds 2 TextFields with Labels
      and an OK/Cancel Button.

      ======================================================================

            lbunnisunw Lara Bunni (Inactive)
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: