/*
To trigger the bug: Click on each of the four quarters of the grid, in
clockwise order.

Kaffe from Debian. -version gives 
'Engine: Just-in-time   Version: 1.0.7   Java Version: 1.1'

Output is:
Clicked java.awt.Canvas[canvas0,0,0,48x62] at java.awt.Point[x=33,y=40]
Clicked java.awt.Label[null,48,0,48x62,Label: a] at java.awt.Point[x=64,y=36]
Clicked java.awt.Panel[null,48,62,48x62,layout=java.awt.FlowLayout] at java.awt.Point[x=69,y=98]

Sun's JRE 1.1. -version gives 'java version "1.1.8"'. No output


Why this is a serious bug: Because programs written with Kaffe to
depend on getting those clicks will break on the Sun JRE.  I believe
the behavior is the same on later JREs, but it could be some other
breakage causing similar symptoms.  I don't have easy access to
anything but 1.1.

 */
import java.awt.*;
import java.awt.event.*;

public class DemoPanelBug extends Frame {
    class TestListener extends MouseAdapter {
	public void mouseClicked (MouseEvent e) {
	    System.out.println("event: " + e);
	    Object clicked = getComponentAt (e.getPoint ());
	    System.out.println ("Clicked " + clicked + " at " + e.getPoint ());   
	}
    }

    public DemoPanelBug () {
	setLayout (new GridLayout (2, 2));

	Component parts [] = new Component [] {
	    new Canvas (), new Label ("a"), 
	    new Button ("b"), new Panel ()};

	for (int i = 0; i < 4; i++) {
	    add (parts [i]);
	}

	// add a mouse listener to top frame to show
	// that events propagate up when they are not
	// handled
	addMouseListener (new TestListener());

	// add a mouse listener to the button, to
	// show that events are received by laid
	// out components.
	parts[2].addMouseListener(new TestListener());

	pack ();
	show ();

	System.out.println("enabled: " + isEnabled());
	System.out.println(this);
	for (int i = 0; i < parts.length; ++i) {
	    System.out.println(parts[i]);
	}
    }
    //unimportant stuff

    public static void main (String args []) {
	new DemoPanelBug ();
    }
}
