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

RequestFocus does not bring focus to component in Netscape 7 on Solaris

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P1 P1
    • 5.0
    • 1.0
    • client-libs
    • None
    • beta
    • sparc
    • solaris_8

      Running Netscape 7.0 on Solaris 8.

      Customer has an applet with some textfileds and buttons. The code has RequestFocus() call to set the focus on one of the text fields when the applet gets loaded. The focus is not getting set to the text field when using Netscape 7 on Solaris 8.

      However, the same code works fine on Netscape 7 on Windows and Netscape 6.x on Solaris.

      ====================Test Code================

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

      //<HTML>
      //<HEAD>
      //<TITLE>Tabbing Test</TITLE>
      //</HEAD>
      //<BODY>
      //<APPLET CODE="Sample.class" CODEBASE="." id=MyApplet name=MyApplet WIDTH=400 //HEIGHT=400 >

      //</APPLET>

      //</BODY>
      //</HTML>

      public class Sample extends Applet implements ActionListener, FocusListener
      {
              TextField txtname,txtpass;
              Label lblname, lblpass;
              Button btnlogin, btncancel;
              String msg="";

              public void init()
              {
                      lblname = new Label("Name : ", Label.RIGHT);
                      lblpass = new Label("Password :", Label.RIGHT);
                      txtname = new TextField(12);
                      txtpass = new TextField(8);
                      txtpass.setEchoChar('*');

                      GridLayout grid = new GridLayout(5,2);

                      setFont(new Font("Helvetica", Font.PLAIN, 14));
                      setLayout(grid);

                      btnlogin = new Button("Login");
                      btncancel = new Button("Password");

                      add(lblname);
                      add(txtname);
                      add(lblpass);
                      add(txtpass);
                      add(btnlogin);
                      add(btncancel);

                      txtname.requestFocus();

                      txtname.addActionListener(this);
                      txtpass.addActionListener(this);
                      btnlogin.addActionListener(this);
                      btncancel.addActionListener(this);
                      txtname.addFocusListener(this);
                      txtpass.addFocusListener(this);
              }
       public void start()
              {
                      repaint();
              }
              public void actionPerformed(ActionEvent ae)
              {
                      repaint();
                      Label x = new Label ("Clicked");
                      String str = ae.getActionCommand();
                      if(str.equals("Login"))
                      {
                              msg = "ButtonClicked : Yes";
                      }
                      else if(str.equals("No"))
                      {
                              msg = "ButtonClicked : No";
                      }

              }
              public void paint(Graphics g)
      {
                      g.drawString(msg,6,40);
                      g.drawString("Name: " + txtname.getText(),6,60);
                      g.drawString("selected Text: " + txtname.getSelectedText(),6,80)
      ;
                      g.drawString("Password :" + txtpass.getText(),6,100);
              }

              public void focusGained(FocusEvent fe)
              {
                      Component c= fe.getComponent();
                      if (c instanceof TextField)
                              c.setBackground(Color.cyan);

              }

              public void focusLost(FocusEvent fe)
              {
                      Component c= fe.getComponent();
                      if (c instanceof TextField)
                              c.setBackground(Color.white);

              }
      }


            dmikhalksunw Denis Mikhalkin (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: