-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
6u10
FULL PRODUCT VERSION :
Java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03) Java HotSpot(TM) Server VM (build 11.3-b02, mixed mode)
Using the Next generation Java plugin.
ADDITIONAL OS VERSION INFORMATION :
Linux xxxxxxxxxx 2.6.27.21-170.2.56.fc10.i686 #1 SMP Mon Mar 23 23:37:54 EDT 2009 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Focus not restored in applet after closing a modal dialog launched from the applet. Attached is a testcase, which is an applet.
Once when the applet is launched, click on the "Launch Dialog" button, this will bring up a modal dialog with a button "T". Now close this modal dialog.
Observe that focus is not restored on the "Launch Dialog" button.
This works in the jres less than or equal to 1.6.0_07.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Launch the applet described in the test case
2. Click on Launch Dialog button
3. Close the modal dialog
4. Observe that focus is not restored.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Focus should be restored on Launch Dialog button
ACTUAL -
Focus not restored on Launch Dialog button
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package lab;
import java.awt.BorderLayout;
import java.awt.KeyboardFocusManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class FocusTest extends JApplet {
@Override
public void init() {
final JButton b = new JButton("Launch Dialog");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final JDialog d = new JDialog(
JOptionPane.getFrameForComponent(FocusTest.this.getContentPane()));
d.setTitle("Test");
d.setModal(true);
JButton b1 = new JButton("T");
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Test");
System.out.println(d.getParent());
}
});
d.getContentPane().add(b1);
d.pack();
d.setVisible(true);
//Workaround
//d.getParent().transferFocus();
//b.requestFocus();
}
});
KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
System.out.println("PropName : " + evt.getPropertyName());
System.out.println("oldValue : " + evt.getOldValue());
System.out.println("newValue : " + ((evt.getNewValue() == null) ? null : evt.getNewValue().getClass()));
System.out.println("*******************************");
}
});
this.getContentPane().add(b);
this.getContentPane().add(new JTextField(25),BorderLayout.SOUTH);
}
}
<APPLET CODE = "lab.FocusTest" WIDTH = "800" HEIGHT = "800" MAYSCRIPT = "mayscript">
</APPLET>
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
explicitly call requestfocus
Release Regression From : 6u7
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
Java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03) Java HotSpot(TM) Server VM (build 11.3-b02, mixed mode)
Using the Next generation Java plugin.
ADDITIONAL OS VERSION INFORMATION :
Linux xxxxxxxxxx 2.6.27.21-170.2.56.fc10.i686 #1 SMP Mon Mar 23 23:37:54 EDT 2009 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Focus not restored in applet after closing a modal dialog launched from the applet. Attached is a testcase, which is an applet.
Once when the applet is launched, click on the "Launch Dialog" button, this will bring up a modal dialog with a button "T". Now close this modal dialog.
Observe that focus is not restored on the "Launch Dialog" button.
This works in the jres less than or equal to 1.6.0_07.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Launch the applet described in the test case
2. Click on Launch Dialog button
3. Close the modal dialog
4. Observe that focus is not restored.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Focus should be restored on Launch Dialog button
ACTUAL -
Focus not restored on Launch Dialog button
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package lab;
import java.awt.BorderLayout;
import java.awt.KeyboardFocusManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class FocusTest extends JApplet {
@Override
public void init() {
final JButton b = new JButton("Launch Dialog");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final JDialog d = new JDialog(
JOptionPane.getFrameForComponent(FocusTest.this.getContentPane()));
d.setTitle("Test");
d.setModal(true);
JButton b1 = new JButton("T");
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Test");
System.out.println(d.getParent());
}
});
d.getContentPane().add(b1);
d.pack();
d.setVisible(true);
//Workaround
//d.getParent().transferFocus();
//b.requestFocus();
}
});
KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
System.out.println("PropName : " + evt.getPropertyName());
System.out.println("oldValue : " + evt.getOldValue());
System.out.println("newValue : " + ((evt.getNewValue() == null) ? null : evt.getNewValue().getClass()));
System.out.println("*******************************");
}
});
this.getContentPane().add(b);
this.getContentPane().add(new JTextField(25),BorderLayout.SOUTH);
}
}
<APPLET CODE = "lab.FocusTest" WIDTH = "800" HEIGHT = "800" MAYSCRIPT = "mayscript">
</APPLET>
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
explicitly call requestfocus
Release Regression From : 6u7
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.