-
Bug
-
Resolution: Won't Fix
-
P4
-
7u7
FULL PRODUCT VERSION :
jdk6 / jdk7u7 / development builds of JDK8
ADDITIONAL OS VERSION INFORMATION :
Linux localhost.localdomain 3.5.4-1.fc17.x86_64 #1 SMP Mon Sep 17 15:03:59 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Fedora 17
EXTRA RELEVANT SYSTEM CONFIGURATION :
Firefox-15.0.1
A DESCRIPTION OF THE PROBLEM :
We ran into weird focus problems when running our application in applet-mode, which provides autocompletition for JTextFields using a JPopup.
I was able to create a simple, self-contained test-case which unfroutunatly only triggers the problem on Linux, whereas in our real application it happens on windows also:
The JTextField opens up a JPopupMenu on <ENTER>, which can be closed
by clicking the JButton it contains.
However, after the popup is hidden, no editing is possible unless
focus is toggled once between the browser and another window.
Unfourtunatly the testcase only triggers the problem on Linux (tested
with jdk8+ customer plugin as well as openjdk7+icedtea-web both with
recent versions Firefox and Chrome).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the source attached
2. Load it in a browser on a linux machine
3. Click into the JTextField and type a few words (should work)
4. Now press the <ENTER> key, this will open a JPopup
5. Click the button inside the JPopup to hide it again
6. Now its not possible to enter any text in the JTextfield
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After the JPopup is hidden again, the JTextfield should receive and process text input
ACTUAL -
After the JPopup is hidden, the JTextField doesn't seem to receive key-events
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestFieldInputApplet extends JApplet {
JTextField field;
TestPopup popup;
public TestFieldInputApplet() {
field = new JTextField("First press <ENTER>, a popup menu will appear, click the close button. Then try to edit the text field");
popup = new TestPopup();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(field);
field.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
popup.show(e.getComponent(), 0, e.getComponent().getHeight() + 5);
}
}
});
setPreferredSize(new Dimension(300, 300));
}
}
class TestPopup extends JPopupMenu {
JButton closeBtn;
public TestPopup() {
closeBtn = new JButton("Close");
this.add(closeBtn);
this.setLightWeightPopupEnabled(true);
closeBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
}
@Override
public void show(Component invoker, int x, int y) {
setPreferredSize(new Dimension(500, 200));
revalidate();
super.show(invoker, x, y);
}
}
<html>
<BODY>
<APPLET
CODE = "TestFieldInputApplet"
WIDTH = "750" HEIGHT = "200">
</APPLET>
</body>
</html>
jdk6 / jdk7u7 / development builds of JDK8
ADDITIONAL OS VERSION INFORMATION :
Linux localhost.localdomain 3.5.4-1.fc17.x86_64 #1 SMP Mon Sep 17 15:03:59 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Fedora 17
EXTRA RELEVANT SYSTEM CONFIGURATION :
Firefox-15.0.1
A DESCRIPTION OF THE PROBLEM :
We ran into weird focus problems when running our application in applet-mode, which provides autocompletition for JTextFields using a JPopup.
I was able to create a simple, self-contained test-case which unfroutunatly only triggers the problem on Linux, whereas in our real application it happens on windows also:
The JTextField opens up a JPopupMenu on <ENTER>, which can be closed
by clicking the JButton it contains.
However, after the popup is hidden, no editing is possible unless
focus is toggled once between the browser and another window.
Unfourtunatly the testcase only triggers the problem on Linux (tested
with jdk8+ customer plugin as well as openjdk7+icedtea-web both with
recent versions Firefox and Chrome).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the source attached
2. Load it in a browser on a linux machine
3. Click into the JTextField and type a few words (should work)
4. Now press the <ENTER> key, this will open a JPopup
5. Click the button inside the JPopup to hide it again
6. Now its not possible to enter any text in the JTextfield
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After the JPopup is hidden again, the JTextfield should receive and process text input
ACTUAL -
After the JPopup is hidden, the JTextField doesn't seem to receive key-events
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestFieldInputApplet extends JApplet {
JTextField field;
TestPopup popup;
public TestFieldInputApplet() {
field = new JTextField("First press <ENTER>, a popup menu will appear, click the close button. Then try to edit the text field");
popup = new TestPopup();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(field);
field.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
popup.show(e.getComponent(), 0, e.getComponent().getHeight() + 5);
}
}
});
setPreferredSize(new Dimension(300, 300));
}
}
class TestPopup extends JPopupMenu {
JButton closeBtn;
public TestPopup() {
closeBtn = new JButton("Close");
this.add(closeBtn);
this.setLightWeightPopupEnabled(true);
closeBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
}
@Override
public void show(Component invoker, int x, int y) {
setPreferredSize(new Dimension(500, 200));
revalidate();
super.show(invoker, x, y);
}
}
<html>
<BODY>
<APPLET
CODE = "TestFieldInputApplet"
WIDTH = "750" HEIGHT = "200">
</APPLET>
</body>
</html>