001: /*
002: * Copyright (C) 2004 NNL Technology AB
003: * Visit www.infonode.net for information about InfoNode(R)
004: * products and how to contact NNL Technology AB.
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
019: * MA 02111-1307, USA.
020: */
021:
022: // $Id: DraggableComponentBox.java,v 1.52 2005/12/04 13:46:03 jesper Exp $
023: package net.infonode.gui.draggable;
024:
025: import net.infonode.gui.*;
026: import net.infonode.gui.layout.DirectionLayout;
027: import net.infonode.gui.panel.SimplePanel;
028: import net.infonode.util.Direction;
029:
030: import javax.swing.*;
031: import java.awt.*;
032: import java.awt.event.ComponentAdapter;
033: import java.awt.event.ComponentEvent;
034: import java.util.ArrayList;
035:
036: public class DraggableComponentBox extends SimplePanel {
037: private boolean componentBoxEnabled = true;
038:
039: private JComponent componentBox;
040: private JComponent componentContainer;
041:
042: private JComponent outerParentArea = this ;
043: private Direction componentDirection = Direction.UP;
044: private boolean scrollEnabled = false;
045: private boolean ensureSelectedVisible;
046: private boolean autoSelect = true;
047: private boolean descendingSortOrder = true;
048:
049: private boolean doReverseSort = false;
050: private boolean mustSort = false;
051:
052: private int scrollOffset;
053: private int iconSize;
054: private DraggableComponent selectedComponent;
055: private DraggableComponent topComponent;
056: private ArrayList listeners;
057: private ArrayList draggableComponentList = new ArrayList(10);
058: private ArrayList layoutOrderList = new ArrayList(10);
059:
060: private ScrollButtonBox scrollButtonBox;
061:
062: private boolean useDefaultScrollButtons = true;
063:
064: private DraggableComponentListener draggableComponentListener = new DraggableComponentListener() {
065: public void changed(DraggableComponentEvent event) {
066: if (event.getType() == DraggableComponentEvent.TYPE_MOVED) {
067: sortComponentList(!descendingSortOrder);
068: }
069: fireChangedEvent(event);
070: }
071:
072: public void selected(DraggableComponentEvent event) {
073: doSelectComponent(event.getSource());
074: }
075:
076: public void dragged(DraggableComponentEvent event) {
077: fireDraggedEvent(event);
078: }
079:
080: public void dropped(DraggableComponentEvent event) {
081: ensureSelectedVisible();
082: fireDroppedEvent(event);
083: }
084:
085: public void dragAborted(DraggableComponentEvent event) {
086: ensureSelectedVisible();
087: fireNotDroppedEvent(event);
088: }
089: };
090:
091: public DraggableComponentBox(int iconSize) {
092: this (iconSize, true);
093: }
094:
095: public DraggableComponentBox(int iconSize,
096: boolean useDefaultScrollButtons) {
097: this .iconSize = iconSize;
098: this .useDefaultScrollButtons = useDefaultScrollButtons;
099: // Fix minimum size when flipping direction
100: final DirectionLayout layout = new DirectionLayout(
101: componentDirection == Direction.UP ? Direction.RIGHT
102: : componentDirection == Direction.LEFT ? Direction.DOWN
103: : componentDirection == Direction.DOWN ? Direction.RIGHT
104: : Direction.DOWN) {
105: public Dimension minimumLayoutSize(Container parent) {
106: Dimension min = super .minimumLayoutSize(parent);
107: Dimension pref = super .preferredLayoutSize(parent);
108: return componentDirection.isHorizontal() ? new Dimension(
109: pref.width, min.height)
110: : new Dimension(min.width, pref.height);
111: }
112:
113: public void layoutContainer(Container parent) {
114: if (DraggableComponentBox.this != null
115: && componentBoxEnabled) {
116: //long millis = System.currentTimeMillis();
117: doSort();
118: super .layoutContainer(parent);
119: //System.out.println("Layout: " + (System.currentTimeMillis() - millis));
120: }
121: }
122:
123: public Dimension preferredLayoutSize(Container parent) {
124: doSort();
125: return super .preferredLayoutSize(parent);
126: }
127: };
128:
129: layout.setLayoutOrderList(layoutOrderList);
130:
131: componentBox = new SimplePanel(layout) {
132: public boolean isOptimizedDrawingEnabled() {
133: return DraggableComponentBox.this != null
134: && getComponentSpacing() >= 0;
135: }
136: };
137:
138: componentBox.addComponentListener(new ComponentAdapter() {
139: public void componentResized(ComponentEvent e) {
140: //fireChangedEvent();
141: }
142:
143: public void componentMoved(ComponentEvent e) {
144: fireChangedEvent();
145: }
146: });
147:
148: initialize();
149: }
150:
151: public void addListener(DraggableComponentBoxListener listener) {
152: if (listeners == null)
153: listeners = new ArrayList(2);
154:
155: listeners.add(listener);
156: }
157:
158: public void removeListener(DraggableComponentBoxListener listener) {
159: if (listeners != null) {
160: listeners.remove(listener);
161:
162: if (listeners.size() == 0)
163: listeners = null;
164: }
165: }
166:
167: public void addDraggableComponent(DraggableComponent component) {
168: insertDraggableComponent(component, -1);
169: }
170:
171: public void insertDraggableComponent(DraggableComponent component,
172: int index) {
173: component.setLayoutOrderList(layoutOrderList);
174:
175: component.addListener(draggableComponentListener);
176: if (index < 0) {
177: layoutOrderList.add(component.getComponent());
178: componentBox.add(component.getComponent());
179: } else {
180: layoutOrderList.add(index, component.getComponent());
181: componentBox.add(component.getComponent(), index);
182: }
183:
184: sortComponentList(!descendingSortOrder);
185:
186: draggableComponentList.add(component);
187: component.setOuterParentArea(outerParentArea);
188: componentBox.revalidate();
189:
190: fireAddedEvent(component);
191: if (autoSelect && layoutOrderList.size() == 1
192: && selectedComponent == null && component.isEnabled())
193: doSelectComponent(component);
194:
195: updateScrollButtons();
196: }
197:
198: private void updateScrollButtons() {
199: if (scrollButtonBox != null) {
200: ScrollableBox scrollableBox = (ScrollableBox) componentContainer;
201: scrollButtonBox.setButton1Enabled(!scrollableBox
202: .isLeftEnd());
203: scrollButtonBox.setButton2Enabled(!scrollableBox
204: .isRightEnd());
205: }
206: }
207:
208: public void insertDraggableComponent(DraggableComponent component,
209: Point p) {
210: int componentIndex = getComponentIndexAtPoint(p);
211: if (componentIndex != -1 && layoutOrderList.size() > 0)
212: insertDraggableComponent(component, componentIndex);
213: else
214: insertDraggableComponent(component, -1);
215: }
216:
217: public void selectDraggableComponent(DraggableComponent component) {
218: if (component == null) {
219: if (selectedComponent != null) {
220: DraggableComponent oldSelected = selectedComponent;
221: selectedComponent = null;
222: fireSelectedEvent(selectedComponent, oldSelected);
223: //componentBox.repaint();
224: }
225: } else
226: component.select();
227: }
228:
229: public void removeDraggableComponent(DraggableComponent component) {
230: if (component != null
231: && draggableComponentList.contains(component)) {
232: //component.abortDrag();
233: int index = layoutOrderList.indexOf(component
234: .getComponent());
235: component.removeListener(draggableComponentListener);
236: if (component == topComponent)
237: topComponent = null;
238: if (layoutOrderList.size() > 1 && selectedComponent != null) {
239: if (selectedComponent == component) {
240: if (autoSelect) {
241: int selectIndex = findSelectableComponentIndex(index);
242: if (selectIndex > -1)
243: selectDraggableComponent(findDraggableComponent((Component) layoutOrderList
244: .get(selectIndex)));
245: else
246: selectedComponent = null;
247: } else {
248: selectDraggableComponent(null);
249: }
250: }
251: } else {
252: if (selectedComponent != null) {
253: DraggableComponent oldSelected = selectedComponent;
254: selectedComponent = null;
255: fireSelectedEvent(selectedComponent, oldSelected);
256: }
257: }
258: draggableComponentList.remove(component);
259: layoutOrderList.remove(component.getComponent());
260: componentBox.remove(component.getComponent());
261: componentBox.revalidate();
262: //componentBox.validate();
263: component.setLayoutOrderList(null);
264:
265: sortComponentList(!descendingSortOrder);
266:
267: updateScrollButtons();
268:
269: fireRemovedEvent(component);
270: }
271: }
272:
273: public boolean containsDraggableComponent(
274: DraggableComponent component) {
275: return draggableComponentList.contains(component);
276: }
277:
278: public DraggableComponent getSelectedDraggableComponent() {
279: return selectedComponent;
280: }
281:
282: public int getDraggableComponentCount() {
283: return layoutOrderList.size();
284: }
285:
286: public DraggableComponent getDraggableComponentAt(int index) {
287: return index < layoutOrderList.size() ? findDraggableComponent((Component) layoutOrderList
288: .get(index))
289: : null;
290: }
291:
292: public int getDraggableComponentIndex(DraggableComponent component) {
293: return layoutOrderList.indexOf(component.getComponent());
294: }
295:
296: public Object[] getDraggableComponents() {
297: return draggableComponentList.toArray();
298: }
299:
300: public Component[] getBoxComponents() {
301: return componentBox.getComponents();
302: }
303:
304: public boolean getDepthSortOrder() {
305: return descendingSortOrder;
306: }
307:
308: public void setDepthSortOrder(boolean descending) {
309: if (descending != this .descendingSortOrder) {
310: this .descendingSortOrder = descending;
311: sortComponentList(!descending);
312: doSort();
313: }
314: }
315:
316: public boolean isScrollEnabled() {
317: return scrollEnabled;
318: }
319:
320: public void setScrollEnabled(boolean scrollEnabled) {
321: if (scrollEnabled != this .scrollEnabled) {
322: this .scrollEnabled = scrollEnabled;
323: initialize();
324: }
325: }
326:
327: public int getScrollOffset() {
328: return scrollOffset;
329: }
330:
331: public void setScrollOffset(int scrollOffset) {
332: if (scrollOffset != this .scrollOffset) {
333: this .scrollOffset = scrollOffset;
334: if (scrollEnabled)
335: ((ScrollableBox) componentContainer)
336: .setScrollOffset(scrollOffset);
337: }
338: }
339:
340: public int getComponentSpacing() {
341: return getDirectionLayout().getComponentSpacing();
342: }
343:
344: public void setComponentSpacing(int componentSpacing) {
345: if (componentSpacing != getDirectionLayout()
346: .getComponentSpacing()) {
347: if (getComponentSpacing() < 0 && componentSpacing >= 0) {
348: DraggableComponent tmp = topComponent;
349: sortComponentList(false);
350: topComponent = tmp;
351: }
352: getDirectionLayout().setComponentSpacing(componentSpacing);
353: sortComponentList(!descendingSortOrder);
354: componentBox.revalidate();
355: }
356: }
357:
358: public boolean isEnsureSelectedVisible() {
359: return ensureSelectedVisible;
360: }
361:
362: public void setEnsureSelectedVisible(boolean ensureSelectedVisible) {
363: this .ensureSelectedVisible = ensureSelectedVisible;
364: }
365:
366: public boolean isAutoSelect() {
367: return autoSelect;
368: }
369:
370: public void setAutoSelect(boolean autoSelect) {
371: this .autoSelect = autoSelect;
372: }
373:
374: public Direction getComponentDirection() {
375: return componentDirection;
376: }
377:
378: public void setComponentDirection(Direction componentDirection) {
379: if (componentDirection != this .componentDirection) {
380: this .componentDirection = componentDirection;
381: getDirectionLayout()
382: .setDirection(
383: componentDirection == Direction.UP ? Direction.RIGHT
384: : componentDirection == Direction.LEFT ? Direction.DOWN
385: : componentDirection == Direction.DOWN ? Direction.RIGHT
386: : Direction.DOWN);
387: if (scrollEnabled) {
388: scrollButtonBox.setVertical(componentDirection
389: .isHorizontal());
390: ((ScrollableBox) componentContainer)
391: .setVertical(componentDirection.isHorizontal());
392: }
393: }
394: }
395:
396: public void setTopComponent(DraggableComponent topComponent) {
397: if (topComponent != this .topComponent) {
398: this .topComponent = topComponent;
399:
400: sortComponentList(!descendingSortOrder);
401: }
402: }
403:
404: public ScrollButtonBox getScrollButtonBox() {
405: return scrollButtonBox;
406: }
407:
408: public JComponent getOuterParentArea() {
409: return outerParentArea;
410: }
411:
412: public void setOuterParentArea(JComponent outerParentArea) {
413: this .outerParentArea = outerParentArea;
414: }
415:
416: public void dragDraggableComponent(DraggableComponent component,
417: Point p) {
418: if (draggableComponentList.contains(component)) {
419: component.drag(SwingUtilities.convertPoint(this , p,
420: component.getComponent()));
421: }
422:
423: //component.drag(SwingUtilities.convertPoint(this, p, component.getComponent()));
424: }
425:
426: public Dimension getMaximumSize() {
427: if (scrollEnabled)
428: return getPreferredSize();
429:
430: if (componentDirection == Direction.LEFT
431: || componentDirection == Direction.RIGHT)
432: return new Dimension((int) getPreferredSize().getWidth(),
433: (int) super .getMaximumSize().getHeight());
434:
435: return new Dimension((int) super .getMaximumSize().getWidth(),
436: (int) getPreferredSize().getHeight());
437:
438: }
439:
440: public Dimension getInnerSize() {
441: boolean mustSort = this .mustSort;
442: this .mustSort = false;
443: Dimension d = scrollEnabled ? componentBox.getPreferredSize()
444: : componentBox.getSize();
445: this .mustSort = mustSort;
446: return d;
447: }
448:
449: public void scrollToVisible(final DraggableComponent c) {
450: SwingUtilities.invokeLater(new Runnable() {
451: public void run() {
452: if (scrollEnabled) {
453: ((ScrollableBox) componentContainer)
454: .ensureVisible(layoutOrderList.indexOf(c
455: .getComponent()));
456: }
457: }
458: });
459: }
460:
461: // Prevents focus problems when adding/removing focused component while sorting when spacing < 0
462: private void setIgnoreAddRemoveNotify(boolean ignore) {
463: for (int i = 0; i < draggableComponentList.size(); i++)
464: ((DraggableComponent) draggableComponentList.get(i))
465: .setIgnoreAddNotify(ignore);
466: }
467:
468: private void doSort() {
469: if (mustSort && getComponentSpacing() < 0) {
470: setIgnoreAddRemoveNotify(true);
471:
472: mustSort = false;
473: Component c;
474: Component tc = topComponent != null ? topComponent
475: .getComponent() : null;
476:
477: //componentBoxEnabled = false;
478:
479: //long millis = System.currentTimeMillis();
480:
481: int index = 0;
482: if (tc != null) {
483: if (componentBox.getComponent(0) != tc) {
484: componentBox.remove(tc);
485: componentBox.add(tc, index);
486: }
487: index++;
488: }
489:
490: int switc = 0;
491: int size = layoutOrderList.size();
492: for (int i = 0; i < size; i++) {
493: c = (Component) layoutOrderList
494: .get(doReverseSort ? size - i - 1 : i);
495: if (c != tc) {
496: if (componentBox.getComponent(index) != c) {
497: switc++;
498: componentBox.remove(c);
499: componentBox.add(c, index);
500: }
501: index++;
502: }
503: }
504:
505: setIgnoreAddRemoveNotify(false);
506:
507: /*System.out.print(" Box: ");
508: for (int i = 0; i < componentBox.getComponentCount(); i++)
509: System.out.print(componentBox.getComponent(i) + " ");
510: System.out.println();
511: System.out.print(" Order: ");
512: for (int i = 0; i < layoutOrderList.size(); i++)
513: System.out.print(layoutOrderList.get(i) + " ");*/
514: //System.out.println();
515: /* long millis = System.currentTimeMillis();
516: componentBox.removeAll();
517:
518: if (tc != null)
519: componentBox.add(tc);
520:
521: int size = layoutOrderList.size();
522: for (int i = 0; i < size; i++) {
523: c = (Component) layoutOrderList.get(doReverseSort ? size - i - 1 : i);
524: if (c != tc)
525: componentBox.add(c);
526: }*/
527:
528: //componentBoxEnabled = true;
529: //System.out.println("Sorting " + scount++ + " time: " + (System.currentTimeMillis() - millis) + " Sorted: " + switc);
530: }
531: }
532:
533: private void sortComponentList(boolean reverseSort) {
534: this .doReverseSort = reverseSort;
535: mustSort = true;
536: }
537:
538: private int getComponentIndexAtPoint(Point p) {
539: JComponent c = null;
540: Point p2 = SwingUtilities.convertPoint(this , p, componentBox);
541: Point p3 = SwingUtilities.convertPoint(componentBox, p,
542: outerParentArea);
543: if (outerParentArea.contains(p3))
544: c = (JComponent) ComponentUtil.getChildAtLine(componentBox,
545: p2, getDirectionLayout().getDirection()
546: .isHorizontal());
547:
548: return layoutOrderList.indexOf(c);
549: }
550:
551: private void doSelectComponent(DraggableComponent component) {
552: if (selectedComponent != null) {
553: DraggableComponent oldSelected = selectedComponent;
554: selectedComponent = component;
555: ensureSelectedVisible();
556: fireSelectedEvent(selectedComponent, oldSelected);
557: } else {
558: selectedComponent = component;
559: ensureSelectedVisible();
560: fireSelectedEvent(selectedComponent, null);
561: }
562: }
563:
564: private int findSelectableComponentIndex(int index) {
565: int selectIndex = -1;
566: int k;
567: for (int i = 0; i < layoutOrderList.size(); i++) {
568: if ((findDraggableComponent((Component) layoutOrderList
569: .get(i))).isEnabled()
570: && i != index) {
571: k = selectIndex;
572: selectIndex = i;
573: if (k < index && selectIndex > index)
574: return selectIndex;
575: else if (k > index && selectIndex > index)
576: return k;
577: }
578: }
579:
580: return selectIndex;
581: }
582:
583: private DraggableComponent findDraggableComponent(Component c) {
584: for (int i = 0; i < draggableComponentList.size(); i++)
585: if (((DraggableComponent) draggableComponentList.get(i))
586: .getComponent() == c)
587: return (DraggableComponent) draggableComponentList
588: .get(i);
589:
590: return null;
591: }
592:
593: private DirectionLayout getDirectionLayout() {
594: return (DirectionLayout) componentBox.getLayout();
595: }
596:
597: private void initialize() {
598: if (componentContainer != null)
599: remove(componentContainer);
600:
601: DirectionLayout layout = getDirectionLayout();
602: layout.setCompressing(!scrollEnabled);
603:
604: if (scrollEnabled) {
605: if (useDefaultScrollButtons)
606: scrollButtonBox = new ScrollButtonBox(
607: componentDirection.isHorizontal(), iconSize);
608: else
609: scrollButtonBox = new ScrollButtonBox(
610: componentDirection.isHorizontal(), null, null,
611: null, null);
612:
613: final ScrollableBox scrollableBox = new ScrollableBox(
614: componentBox, componentDirection.isHorizontal(),
615: scrollOffset);
616: scrollableBox.setLayoutOrderList(layoutOrderList);
617: scrollButtonBox.addListener(new ScrollButtonBoxListener() {
618: public void scrollButton1() {
619: scrollableBox.scrollLeft(1);
620: }
621:
622: public void scrollButton2() {
623: scrollableBox.scrollRight(1);
624: }
625: });
626:
627: scrollableBox.addComponentListener(new ComponentAdapter() {
628: public void componentResized(ComponentEvent e) {
629: scrollButtonBox.setButton1Enabled(!scrollableBox
630: .isLeftEnd());
631: scrollButtonBox.setButton2Enabled(!scrollableBox
632: .isRightEnd());
633: }
634: });
635:
636: scrollButtonBox.setButton1Enabled(!scrollableBox
637: .isLeftEnd());
638: scrollButtonBox.setButton2Enabled(!scrollableBox
639: .isRightEnd());
640:
641: scrollableBox
642: .addScrollableBoxListener(new ScrollableBoxListener() {
643: public void scrolledLeft(ScrollableBox box) {
644: scrollButtonBox.setButton1Enabled(!box
645: .isLeftEnd());
646: scrollButtonBox.setButton2Enabled(true);
647: }
648:
649: public void scrolledRight(ScrollableBox box) {
650: scrollButtonBox.setButton1Enabled(true);
651: scrollButtonBox.setButton2Enabled(!box
652: .isRightEnd());
653: }
654:
655: public void changed(ScrollableBox box) {
656: fireChangedEvent();
657: }
658: });
659: componentContainer = scrollableBox;
660: } else {
661: scrollButtonBox = null;
662: componentContainer = componentBox;
663: }
664:
665: componentContainer.setAlignmentY(0);
666: add(componentContainer, BorderLayout.CENTER);
667:
668: revalidate();
669: }
670:
671: private void ensureSelectedVisible() {
672: SwingUtilities.invokeLater(new Runnable() {
673: public void run() {
674: if (scrollEnabled && ensureSelectedVisible
675: && selectedComponent != null) {
676: //componentContainer.validate();
677: ((ScrollableBox) componentContainer)
678: .ensureVisible(layoutOrderList
679: .indexOf(selectedComponent
680: .getComponent()));
681: }
682: }
683: });
684: }
685:
686: private void fireDraggedEvent(DraggableComponentEvent e) {
687: if (listeners != null) {
688: DraggableComponentBoxEvent event = new DraggableComponentBoxEvent(
689: this , e.getSource(), e, SwingUtilities
690: .convertPoint(e.getSource().getComponent(),
691: e.getMouseEvent().getPoint(), this ));
692: Object[] l = listeners.toArray();
693: for (int i = 0; i < l.length; i++)
694: ((DraggableComponentBoxListener) l[i])
695: .componentDragged(event);
696: }
697: }
698:
699: private void fireDroppedEvent(DraggableComponentEvent e) {
700: if (listeners != null) {
701: DraggableComponentBoxEvent event = new DraggableComponentBoxEvent(
702: this , e.getSource(), e, SwingUtilities
703: .convertPoint(e.getSource().getComponent(),
704: e.getMouseEvent().getPoint(), this ));
705: Object[] l = listeners.toArray();
706: for (int i = 0; i < l.length; i++)
707: ((DraggableComponentBoxListener) l[i])
708: .componentDropped(event);
709: }
710: }
711:
712: private void fireNotDroppedEvent(DraggableComponentEvent e) {
713: if (listeners != null) {
714: DraggableComponentBoxEvent event = new DraggableComponentBoxEvent(
715: this , e.getSource(), e);
716: Object[] l = listeners.toArray();
717: for (int i = 0; i < l.length; i++)
718: ((DraggableComponentBoxListener) l[i])
719: .componentDragAborted(event);
720: }
721: }
722:
723: private void fireSelectedEvent(DraggableComponent component,
724: DraggableComponent oldDraggableComponent) {
725: if (listeners != null) {
726: DraggableComponentBoxEvent event = new DraggableComponentBoxEvent(
727: this , component, oldDraggableComponent);
728: Object[] l = listeners.toArray();
729: for (int i = 0; i < l.length; i++)
730: ((DraggableComponentBoxListener) l[i])
731: .componentSelected(event);
732: }
733: }
734:
735: private void fireAddedEvent(DraggableComponent component) {
736: if (listeners != null) {
737: DraggableComponentBoxEvent event = new DraggableComponentBoxEvent(
738: this , component);
739: Object[] l = listeners.toArray();
740: for (int i = 0; i < l.length; i++)
741: ((DraggableComponentBoxListener) l[i])
742: .componentAdded(event);
743: }
744: }
745:
746: private void fireRemovedEvent(DraggableComponent component) {
747: if (listeners != null) {
748: DraggableComponentBoxEvent event = new DraggableComponentBoxEvent(
749: this , component);
750: Object[] l = listeners.toArray();
751: for (int i = 0; i < l.length; i++)
752: ((DraggableComponentBoxListener) l[i])
753: .componentRemoved(event);
754: }
755: }
756:
757: private void fireChangedEvent(DraggableComponentEvent e) {
758: if (listeners != null) {
759: DraggableComponentBoxEvent event = new DraggableComponentBoxEvent(
760: this , e.getSource(), e);
761: Object[] l = listeners.toArray();
762: for (int i = 0; i < l.length; i++)
763: ((DraggableComponentBoxListener) l[i]).changed(event);
764: }
765: }
766:
767: private void fireChangedEvent() {
768: if (listeners != null) {
769: DraggableComponentBoxEvent event = new DraggableComponentBoxEvent(
770: this );
771: Object[] l = listeners.toArray();
772: for (int i = 0; i < l.length; i++)
773: ((DraggableComponentBoxListener) l[i]).changed(event);
774: }
775: }
776: }
|