-
Bug
-
Resolution: Fixed
-
P3
-
6
-
b53
-
x86
-
windows_2000
-
Verified
Name: azR10139 Date: 01/30/2003
Run the testcase.
Press button "Press to show"
In popped window press with mouse button "Press to hide"
Note, that the frame named "test frame" does not get focus. The only
way to get focus to the frame is to switch to another window
and back to frame.
Seeng the debug output we can say that focus was not transferred from the
hidden window.
--- WinTest.java
import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
public class WinTest {
public static class MyChangeListener implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent evt) {
Object oldF = evt.getOldValue();
Object newF = evt.getNewValue();
System.out.println("window focus changed from: "+oldF);
System.out.println("window focus changed to: "+newF);
}
}
public static class MyActionListener implements ActionListener {
public boolean hideIt;
public Window toHide;
MyActionListener(Window w, boolean b) {
this.toHide = w;
this.hideIt = b;
}
public void actionPerformed(ActionEvent e) {
if(hideIt) {
toHide.dispose();
} else {
toHide.setLocation(200, 200);
toHide.setVisible(true);
}
}
}
public static void main(String args[]) {
KeyboardFocusManager mgr =
KeyboardFocusManager.getCurrentKeyboardFocusManager();
mgr.addPropertyChangeListener("focusedWindow",
new MyChangeListener());
Frame w1 = new Frame("test frame");
Window w2 = new Window(w1);
Button b1 = new Button("Press to show");
b1.addActionListener(new MyActionListener(w2, false));
Button b2 = new Button("Press to hide");
b2.addActionListener(new MyActionListener(w2, true));
w1.add(b1);
w1.setLocation(100, 100);
w1.setSize(50, 50);
w1.show();
w2.add(b2);
w2.setLocation(200, 200);
w2.setSize(80, 80);
}
}
------------------
======================================================================
Run the testcase.
Press button "Press to show"
In popped window press with mouse button "Press to hide"
Note, that the frame named "test frame" does not get focus. The only
way to get focus to the frame is to switch to another window
and back to frame.
Seeng the debug output we can say that focus was not transferred from the
hidden window.
--- WinTest.java
import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
public class WinTest {
public static class MyChangeListener implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent evt) {
Object oldF = evt.getOldValue();
Object newF = evt.getNewValue();
System.out.println("window focus changed from: "+oldF);
System.out.println("window focus changed to: "+newF);
}
}
public static class MyActionListener implements ActionListener {
public boolean hideIt;
public Window toHide;
MyActionListener(Window w, boolean b) {
this.toHide = w;
this.hideIt = b;
}
public void actionPerformed(ActionEvent e) {
if(hideIt) {
toHide.dispose();
} else {
toHide.setLocation(200, 200);
toHide.setVisible(true);
}
}
}
public static void main(String args[]) {
KeyboardFocusManager mgr =
KeyboardFocusManager.getCurrentKeyboardFocusManager();
mgr.addPropertyChangeListener("focusedWindow",
new MyChangeListener());
Frame w1 = new Frame("test frame");
Window w2 = new Window(w1);
Button b1 = new Button("Press to show");
b1.addActionListener(new MyActionListener(w2, false));
Button b2 = new Button("Press to hide");
b2.addActionListener(new MyActionListener(w2, true));
w1.add(b1);
w1.setLocation(100, 100);
w1.setSize(50, 50);
w1.show();
w2.add(b2);
w2.setLocation(200, 200);
w2.setSize(80, 80);
}
}
------------------
======================================================================
- relates to
-
JDK-6516347 java/awt/Focus/DisposedWindow/DisposedWindow.java fails
-
- Closed
-
-
JDK-6276482 Parent window lost its focus after closing child dialog .
-
- Closed
-
-
JDK-6476218 On Linux, Frame does not receives focus after closing of the owned window
-
- Closed
-