-
Bug
-
Resolution: Fixed
-
P2
-
1.1.3
-
1.1.5
-
generic
-
generic
-
Verified
ingrid.yao@Eng 1997-07-29
Problem reported by Oracle:
WM_ACTIVATE processing tries to set the focus to the Component that had the
focus last time the window was activated. WWindowPeer.getFocusPeer() tries to
cast a Component's peer to WComponentPeer, which causes a ClassCastException
for LW Components. The method needs to return the HW ancestor of the LW
Component:
Proposed fix:
WComponentPeer getFocusPeer() {
Component c = ((Window)target).getFocusOwner();
while (c != null) {
ComponentPeer peer = c.getPeer();
if (peer != null && peer instanceof WComponentPeer) {
return (WComponentPeer) peer;
} else {
// peerless sub-component, try parent.
c = c.getParent();
}
}
return null; // no child has focus
}
Test case:
==========
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class b516111
extends Applet
implements WindowListener, FocusListener
{
private Frame _mFrame1;
private lwComponent _mComponent1;
public b516111()
{
}
public void start()
{
_mFrame1 = new Frame("Frame 1");
_mFrame1.setBounds(100, 100, 300, 200);
_mFrame1.setVisible(true);
_mFrame1.addWindowListener(this);
_mFrame1.addFocusListener(this);
_mComponent1 = new lwComponent();
_mFrame1.add(_mComponent1);
_mComponent1.requestFocus();
}
public void windowOpened(WindowEvent e)
{
}
public void windowClosing(WindowEvent e)
{
}
public void windowClosed(WindowEvent e)
{
}
public void windowIconified(WindowEvent e)
{
}
public void windowDeiconified(WindowEvent e)
{
}
public void windowActivated(WindowEvent e)
{
}
public void windowDeactivated(WindowEvent e)
{
}
public void focusGained(FocusEvent e)
{
}
public void focusLost(FocusEvent e)
{
}
}
class lwComponent extends Component
{
public lwComponent()
{
}
}
john.bui@eng 1997-10-17
No specific test case available. Implicity tested, closed with exposure.
- duplicates
-
JDK-4068079 WM_Active does not set focus correctly for LW components
- Closed