-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.2.0
-
sparc
-
solaris_2.5
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
- duplicates
-
JDK-4111728 Problem with keyboard input to Swing in Java Activator
-
- Closed
-