01: package com.xoetrope.carousel.survey;
02:
03: import java.awt.Color;
04: import java.awt.Component;
05: import javax.swing.BorderFactory;
06: import javax.swing.JPopupMenu;
07:
08: /**
09: * A popup panel that can extend beyond its parent and beyond the application window
10: *
11: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
12: * the GNU Public License (GPL), please see license.txt for more details. If
13: * you make commercial use of this software you must purchase a commercial
14: * license from Xoetrope.</p>
15: * <p> $Revision: 1.4 $</p>
16: */
17: public class XPopupPanel extends JPopupMenu {
18: private boolean isReadyToClose = false;
19: private Component owner;
20:
21: public XPopupPanel(Component c) {
22: owner = c;
23: setBorder(BorderFactory.createLineBorder(Color.black));
24: }
25:
26: public void close() {
27: isReadyToClose = true;
28: setVisible(false);
29: }
30:
31: public Component getOwner() {
32: return owner;
33: }
34:
35: /**
36: * Sets the visibility of the popup menu.
37: *
38: * @param b true to make the popup visible, or false to
39: * hide it
40: * @beaninfo
41: * bound: true
42: * description: Makes the popup visible
43: */
44: public void setVisible(boolean b) {
45: // if closing, first close all Submenus
46: if (!b && isReadyToClose)
47: return;
48:
49: super.setVisible(b);
50: }
51: }
|