Name: jk109818 Date: 09/04/2002
FULL PRODUCT VERSION :
java version "1.4.1-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)
FULL OPERATING SYSTEM VERSION :
Debian GNU/Linux, Kernel 2.4.18, libc 2.2.5
A DESCRIPTION OF THE PROBLEM :
A JTextField calling requestFocus() after a JDialog is
closed does not work on Linux with 1.4.1 (beta or RC)
Works fine on Windows.
REGRESSION. Last worked in version 1.4
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Add a JTextField to a frame
2. Launch a JDialog (or JOptionPane)
3. After the dialog closes call JTextField.requestFocus()
EXPECTED VERSUS ACTUAL BEHAVIOR :
With 1.3.1, and 1.4 on Linux and 1.4.1 on Windows the
JTextField is given focus when the dialog closes.
With 1.4.1 on Linux the JTextField does not have focus, ie I
can't type in the TextField without first clicking in it.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestFrame extends JFrame {
private JPanel m_pnlMain = new JPanel();
private JTextField m_txtInput = new JTextField();
private JButton m_btnClickMe = new JButton("Click Me");
private GridBagLayout m_gbLayout = new GridBagLayout();
public TestFrame() {
m_pnlMain.setLayout(m_gbLayout);
m_btnClickMe.addActionListener(new ButtonAdapter(this));
getContentPane().add(m_pnlMain, BorderLayout.CENTER);
m_pnlMain.add(m_btnClickMe, new GridBagConstraints(0, 1, 1, 1,
0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(6,
12, 13, 13), 0, 0));
m_pnlMain.add(m_txtInput, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(13,
12, 6, 13), 50, 0));
}
public static void main(String[] args) {
TestFrame testFrame = new TestFrame();
testFrame.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = testFrame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
testFrame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
testFrame.setVisible(true);
}
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void buttonClicked() {
JOptionPane.showMessageDialog(this, "Test");
m_txtInput.requestFocus();
}
}
class ButtonAdapter implements ActionListener {
private TestFrame adaptee;
ButtonAdapter(TestFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.buttonClicked();
}
}
---------- END SOURCE ----------
Release Regression From : 1.4
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 163804)
======================================================================