JDK-4662240 : REGRESSION : Component.requestFocus() fails for components on JWindow.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: x86
  • Submitted: 2002-04-03
  • Updated: 2002-05-15
  • Resolved: 2002-05-15
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.
Other
1.3.0_02 02Fixed
Related Reports
Relates :  
Description
It's a regression. Bug # 4199374 fails in 14x.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.3.0_02 FIXED IN: 1.3.0_02 INTEGRATED IN: 1.3.0_02 VERIFIED IN: 1.3.0_02
14-06-2004

EVALUATION The tests are supposed to fail, according to current focus specification. A window cannot be focusable unless its owning Frame is visible. Here is an excerpt from focus specification (src/share/classes/java/awt/doc-files/FocusSpec.html, can also be found somewhere on java.sun.com), item called "Focusable Windows":
11-06-2004

WORK AROUND There are two things that we can suggest to the users: 1. Create Windows with visible owners. Attached is modified testcase from bug 4199374 which works just fine. However, Window was not initially supposed to be used like that, it had main purpose of serving as tooltip or a splash-screen. However, pre-1.4, there was no way to create a Frame without decorations, and that made people use the Window (and JWindow) in an unintended way. But in 1.4 we now have 2. Undecorated Frames. Instead of a JWindow, create JFrame, but call setUndecorated(true) on it before showing. That should solve all the problems. In the attached test case, the commented out part about undecorated frames shows how it can be done: comment Window creation, uncomment Frame creation, and it produces the same observable behaviour. --------------------------------------------------------------------- import java.awt.event.*; import javax.swing.*; public class Test { public static void main(String args[]) { final JFrame frame = new JFrame(); JButton button = new JButton("Test"); frame.getContentPane().add(button); frame.pack(); frame.addFocusListener(new NoisyFocusListener("Frame")); button.addFocusListener(new NoisyFocusListener("Button")); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JWindow window = new JWindow(frame); // JFrame window = new JFrame(); // window.setUndecorated(true); JTextField field = new JTextField("Edit Me!"); window.getContentPane().add(field); window.pack(); field.addFocusListener(new NoisyFocusListener("Field")); window.addFocusListener(new NoisyFocusListener("Window")); window.setVisible(true); field.requestFocus(); } }); frame.setVisible(true); } static class NoisyFocusListener implements FocusListener { private String name; public NoisyFocusListener(String name) { this.name = name; } public void focusGained(FocusEvent e) { System.out.println(name + (e.isTemporary() ? " got temporary focus. " : " got focus.")); } public void focusLost(FocusEvent e) { System.out.println(name + (e.isTemporary() ? " lost temporary focus ." : " lost focus.")); } } }
11-06-2004

PUBLIC COMMENTS
10-06-2004