-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.2
-
None
-
sparc
-
solaris_2.5.1
This problem occurs on Solaris, but not on Windows NT.
This example has a Button in a Window, which when pressed causes the button
to move. The problem is that when the Frame that owns the Window is not shown,
and some other Frame is, then the Button ceases to get Action events
(it behaves as if disabled, receiving mouse events but not action).
To demonstrate the problem, run "java Win other"
(other cases that work correctly can be shown with "java Win" "java Win xxx", "java Win both")
Here is the example:
import java.awt.*;
import java.awt.event.*;
public class Win extends Window implements ActionListener {
Button b = new Button("Wow");
public Win(Frame f){
super(f);
setLayout(new BorderLayout());
b.addActionListener(this);
add("Center", b);
System.err.println("calling pack");
setSize(50,50);
setLocation(100,100);
}
public void actionPerformed(ActionEvent e){
Point p = getLocation();
if(p.x>200)hide();
setLocation(p.x+20,p.y+20);
}
public static void main(String[] args){
Frame f = new Frame("Window bug");
if((args.length==0)||(args[0].equals("both"))){
f.add("Center", new Label("Look for another window!"));
f.pack();
f.show();
f.setLocation(300,300);
}
if((args.length>0)&&((args[0].equals("other")||(args[0].equals("both"))))){
Frame xx=new Frame("Other");
xx.add("Center", new Label("Look for another window!"));
xx.pack();
xx.show();
}
Win w = new Win(f);
w.show();
}
}
This example has a Button in a Window, which when pressed causes the button
to move. The problem is that when the Frame that owns the Window is not shown,
and some other Frame is, then the Button ceases to get Action events
(it behaves as if disabled, receiving mouse events but not action).
To demonstrate the problem, run "java Win other"
(other cases that work correctly can be shown with "java Win" "java Win xxx", "java Win both")
Here is the example:
import java.awt.*;
import java.awt.event.*;
public class Win extends Window implements ActionListener {
Button b = new Button("Wow");
public Win(Frame f){
super(f);
setLayout(new BorderLayout());
b.addActionListener(this);
add("Center", b);
System.err.println("calling pack");
setSize(50,50);
setLocation(100,100);
}
public void actionPerformed(ActionEvent e){
Point p = getLocation();
if(p.x>200)hide();
setLocation(p.x+20,p.y+20);
}
public static void main(String[] args){
Frame f = new Frame("Window bug");
if((args.length==0)||(args[0].equals("both"))){
f.add("Center", new Label("Look for another window!"));
f.pack();
f.show();
f.setLocation(300,300);
}
if((args.length>0)&&((args[0].equals("other")||(args[0].equals("both"))))){
Frame xx=new Frame("Other");
xx.add("Center", new Label("Look for another window!"));
xx.pack();
xx.show();
}
Win w = new Win(f);
w.show();
}
}
- duplicates
-
JDK-4094883 Windows don't get mouse events if parent frame hidden (1.1.x only/Solaris only)
-
- Closed
-