JDK-6409185 : Plugin/Mozilla problem - Dismissing popups leave Applet without focus
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 1.4.2_10
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-04-05
  • Updated: 2014-10-14
  • Resolved: 2014-09-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8u40Resolved
Related Reports
Duplicate :  
Relates :  
Description
Having compiled the following code, using it with either the 1.4.2 or 5 Plug-in in Mozilla or Firefox, focus does not return to the applet when you exit a dialogue box using the keyboard.  Instead it returns to the browser's URL bar.  In IE, it works as expected, with focus returning to the Applet when you Alt-C the dialogue.

package test.dialog;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;

import javax.swing.JApplet;
import javax.swing.JDialog;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JTextField;


public class MainApplet extends JApplet {

    private JTextField txtTest = null;
    private JButton btnTest = null;
    private JDialog dlgTest = null;
    
    private GridBagLayout gblTest = null;
        
    public void start() {
        this.txtTest = new JTextField();
        this.btnTest = new JButton("open dialog");
        
        this.gblTest = new GridBagLayout();
        
        this.getContentPane().setLayout(this.gblTest);

        
        
                this.getContentPane().add(this.txtTest, 
                                this.getConstraints(0, 0, 1, 1, 100, 0, 
                                                GridBagConstraints.BOTH, GridBagConstraints.CENTER, 
                                                new Insets(     2,2,2,2),
                                                2, 2));
                this.getContentPane().add(this.btnTest, 
                                this.getConstraints(1, 0, 1, 1, 0, 0, 
                                                GridBagConstraints.BOTH, GridBagConstraints.CENTER, 
                                                new Insets(     2,2,2,2),
                                                2, 2));
                
                this.btnTest.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                dlgTest = new JDialog(JOptionPane.getFrameForComponent(getContentPane()), true);
                                dlgTest.show();
                        }
                });
    }
 
    
    private GridBagConstraints getConstraints(int aGridX, int aGridY, int aGridWidth, 
                int aGridHeight, int aWeightX, int aWeightY,
                int aFill, int aAnchor, Insets aInsets, int aPadX, 
                int aPadY) {
        
        GridBagConstraints constraints = new GridBagConstraints();
        
        constraints.gridx = aGridX;
        constraints.gridy = aGridY;
        constraints.gridwidth = aGridWidth;
        constraints.gridheight = aGridHeight;
        constraints.weightx = aWeightX; 
        constraints.weighty = aWeightY;
        constraints.fill = aFill; 
        constraints.anchor = aAnchor;
        constraints.insets = aInsets;
        constraints.ipadx = aPadX; 
        constraints.ipady = aPadY;
        
        return constraints;
    }
    
}

Switching from a JButton to a Button here (i.e. switching from Swing to AWT) fixes the problem.

Comments
WORK AROUND Use a Button instead of a JButton
05-04-2006