KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > poa > gui > beans > PopupMenu


1 package org.jacorb.poa.gui.beans;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2004 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22  
23 /**
24  * A extended PopupMenu
25  *
26  * @author Reimo Tiedemann, FU Berlin
27  * @version 1.0, 05/07/99, RT
28  */

29 public class PopupMenu
30     extends java.awt.PopupMenu JavaDoc
31 {
32     private java.awt.Component JavaDoc fieldOwnerComponent = null;
33     protected transient java.beans.PropertyChangeSupport JavaDoc propertyChange =
34         new java.beans.PropertyChangeSupport JavaDoc(this);
35
36     /**
37      * Constructor
38      */

39     public PopupMenu() {
40     super();
41     initialize();
42     }
43     /**
44      * PopupMenuBean constructor comment.
45      * @param label java.lang.String
46      */

47     public PopupMenu(java.lang.String JavaDoc label) {
48     super(label);
49     }
50     /**
51      * Performs the show method.
52      * @param mouseEvent java.awt.event.MouseEvent
53      */

54     public void _show(java.awt.Component JavaDoc c, int x, int y) {
55     if (c != null) {
56             setOwnerComponent(c);
57             c.add(this);
58             show(c, x, y);
59     }
60     }
61     /**
62      * Performs the show method.
63      * @param mouseEvent java.awt.event.MouseEvent
64      */

65     public void _show(java.awt.event.MouseEvent JavaDoc mouseEvent) {
66         // if (mouseEvent != null && mouseEvent.isPopupTrigger()) {
67
java.awt.Component JavaDoc popupOwner = mouseEvent.getComponent();
68         if (popupOwner != null) {
69             setOwnerComponent(popupOwner);
70             popupOwner.add(this);
71             show(popupOwner, mouseEvent.getX(), mouseEvent.getY());
72         }
73         // }
74
}
75     /**
76      * PopupMenuBean.addPropertyChangeListener method comment.
77      */

78     public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener JavaDoc listener) {
79     propertyChange.addPropertyChangeListener(listener);
80     }
81     /**
82      * PopupMenuBean.firePropertyChange method comment.
83      */

84     public void firePropertyChange(java.lang.String JavaDoc propertyName, java.lang.Object JavaDoc oldValue, java.lang.Object JavaDoc newValue) {
85     propertyChange.firePropertyChange(propertyName, oldValue, newValue);
86     }
87     /**
88      * Gets the ownerComponent property (java.awt.Component) value.
89      * @return The ownerComponent property value.
90      * @see #setOwnerComponent
91      */

92     public java.awt.Component JavaDoc getOwnerComponent() {
93     /* Returns the ownerComponent property value. */
94     return fieldOwnerComponent;
95     }
96     /**
97      * Called whenever the part throws an exception.
98      * @param exception java.lang.Throwable
99      */

100     private void handleException(Throwable JavaDoc exception) {
101
102     /* Uncomment the following lines to print uncaught exceptions to stdout */
103     // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
104
// exception.printStackTrace(System.out);
105
}
106     /**
107      * Initialize the class.
108      */

109     /* WARNING: THIS METHOD WILL BE REGENERATED. */
110     private void initialize() {
111     // user code begin {1}
112
// user code end
113
// user code begin {2}
114
// user code end
115
}
116     /**
117      * main entrypoint - starts the part when it is run as an application
118      * @param args java.lang.String[]
119      */

120     public static void main(java.lang.String JavaDoc[] args) {
121     try {
122             org.jacorb.poa.gui.beans.PopupMenu aExtendedPopupMenu =
123                 new org.jacorb.poa.gui.beans.PopupMenu();
124     } catch (Throwable JavaDoc exception) {
125             System.err.println("Exception occurred in main() of org.jacorb.poa.gui.beans.PopupMenu");
126             exception.printStackTrace(System.out);
127     }
128     }
129     /**
130      * PopupMenuBean.removePropertyChangeListener method comment.
131      */

132     public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener JavaDoc listener) {
133     propertyChange.removePropertyChangeListener(listener);
134     }
135     /**
136      * Sets the ownerComponent property (java.awt.Component) value.
137      * @param ownerComponent The new value for the property.
138      * @see #getOwnerComponent
139      */

140     public void setOwnerComponent(java.awt.Component JavaDoc ownerComponent) {
141     /* Get the old property value for fire property change event. */
142     java.awt.Component JavaDoc oldValue = fieldOwnerComponent;
143     /* Set the ownerComponent property (attribute) to the new value. */
144     fieldOwnerComponent = ownerComponent;
145     /* Fire (signal/notify) the ownerComponent property change event. */
146     firePropertyChange("ownerComponent", oldValue, ownerComponent);
147     return;
148     }
149
150 }
151
152
153
154
155
156
157
158
159
160
161
162
163
Popular Tags