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

Changing the content of a JApplet in an application, JTextField and JTextArea ca

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description


      Swing : swing-1.0
      Platform : NT

      In an application, if JApplet is the top level container, changing the content of the container prevents JTextField and JTextArea from getting focus. (NOTE : this only happens on NT. This bug doesn't show on Solaris)

      In the following test case, a JFrame contains a JApplet as the top level container which contains a JButton. Push the JButton to change the content of the container. The new components are JTextField, JTextArea and a JCheckBox. Both JTextField and JTextArea cannot get focus.

      /**
       * @author Patience Chu
       */
      import com.sun.java.swing.*;
      import com.sun.java.swing.text.*;

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

      public class Zippy extends JApplet
      {
        //variables.
        public void init(){
          getContentPane().setLayout(new BorderLayout());

          setForeground(Color.black);
          setBackground(Color.lightGray);

          JButton button = new JButton("Push to change content");
          button.setBackground(Color.black);
          button.setForeground(Color.yellow);
          button.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent e){
      showZippy();
            }
          });

          getContentPane().add("Center",button);
        }

        public void showZippy(){
        
          setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

          getContentPane().removeAll();
          getContentPane().add("Center",new JTextArea("Hello, This is a JTextArea"));
          getContentPane().add("South",new JTextField("a a JTextField"));
          getContentPane().add("North", new JCheckBox("a JCheckBox"));

          invalidate();
          validate();
          repaint();
          setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

        }

        /**
          * main method.
          */
        public static void main(String args[]){
          String yourVersion = System.getProperty("java.version");
          System.out.println("Your JDK version: "+yourVersion);

          JFrame frame = new JFrame("Zip File Browser");
          Zippy theApplet = new Zippy();
       
          frame.getContentPane().add(theApplet, "Center");
          frame.setBackground(Color.lightGray);

          frame.setSize(200,100);
          frame.setLocation(300, 300);
          // frame.pack();

          WindowListener l = new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
          };
          frame.addWindowListener(l);

          theApplet.init();
          frame.show();
        }

      }
      patience.chu@Eng 1998-02-13

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tballsunw Tom Ball (Inactive)
              Reporter:
              pchusunw Patience Chu (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: