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

Focus is set to the first component after resizing main window.

XMLWordPrintable

    • hopper
    • sparc
    • solaris_2.5.1, solaris_8
    • Verified



      Name: tb29552 Date: 06/24/97


      1. - Start the sample programm.
         - Click on the second button.
         - Click on the last button.
         - Now the TextField will have the focus.

       I tried to implement a context sensitive status bar, but it does
       not work, because every time a new status bar should be displayed,
       the main window is resized and the focus is changed to the first
       component.

       2. Example source:

       import java.awt.*;
       import java.awt.event.*;

       public class FocusBug extends Frame implements ActionListener {
               public FocusBug() {
                       setLayout(new GridLayout(3, 1));
                       add(new TextField("Has focus after resize"));
                       add(new Button("Give me the focus please!"));
                       add(new Button("Test it!"));
                       ((Button)getComponent(2)).addActionListener(this);
                       pack();
               }

               public void actionPerformed(ActionEvent e) {
                      setSize(200, 200);
                      doLayout();
                      pack();
               }

               public static void main(String[] args) {
                       FocusBug window = new FocusBug();
                       window.show();
               }
      }
      company - TS Softwareentwicklung , email - ###@###.###
      ======================================================================

            dmikhalksunw Denis Mikhalkin (Inactive)
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: