01: // DnDJPanel.java
02: // $Id: DnDJPanel.java,v 1.3 2000/08/16 21:37:31 ylafon Exp $
03: // (c) COPYRIGHT MIT, INRIA and Keio, 1999.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.jigadmin.widgets;
07:
08: import java.awt.Component;
09: import java.awt.Container;
10: import java.awt.LayoutManager;
11:
12: import javax.swing.JPanel;
13:
14: /**
15: * A JPanel for dnd (work arround for a bug in swing)
16: * @version $Revision: 1.3 $
17: * @author Benoît Mahé (bmahe@w3.org)
18: */
19: public class DnDJPanel extends JPanel {
20:
21: public DnDJPanel() {
22: super ();
23: }
24:
25: public DnDJPanel(boolean isDoubleBuffered) {
26: super (isDoubleBuffered);
27: }
28:
29: public DnDJPanel(LayoutManager layout) {
30: super (layout);
31: }
32:
33: public DnDJPanel(LayoutManager layout, boolean isDoubleBuffered) {
34: super (layout, isDoubleBuffered);
35: }
36:
37: public Component findComponentAt(int x, int y) {
38: if (!contains(x, y)) {
39: return null;
40: }
41: int ncomponents = getComponentCount();
42: Component components[] = getComponents();
43: for (int i = 0; i < ncomponents; i++) {
44: Component comp = components[i];
45: if (comp != null) {
46: if (comp instanceof Container) {
47: if (comp.isVisible())
48: comp = ((Container) comp).findComponentAt(x
49: - comp.getX(), y - comp.getY());
50: } else {
51: comp = comp.getComponentAt(x - comp.getX(), y
52: - comp.getY());
53: }
54: if (comp != null && comp.isVisible()) {
55: return comp;
56: }
57: }
58: }
59: return this;
60: }
61:
62: }
|