KickJava   Java API By Example, From Geeks To Geeks.

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


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

21 package org.jacorb.poa.gui.beans;
22
23 public class ExtendedPopupMenu
24     extends java.awt.PopupMenu JavaDoc
25 {
26     private java.awt.Component JavaDoc fieldOwnerComponent = null;
27
28     protected transient java.beans.PropertyChangeSupport JavaDoc propertyChange =
29         new java.beans.PropertyChangeSupport JavaDoc(this);
30     /**
31      * Constructor
32      */

33     /* WARNING: THIS METHOD WILL BE REGENERATED. */
34     public ExtendedPopupMenu() {
35     super();
36     initialize();
37     }
38     /**
39      * PopupMenuBean constructor comment.
40      * @param label java.lang.String
41      */

42     public ExtendedPopupMenu(java.lang.String JavaDoc label) {
43     super(label);
44     }
45     /**
46      * PopupMenuBean.addPropertyChangeListener method comment.
47      */

48     public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener JavaDoc listener) {
49     propertyChange.addPropertyChangeListener(listener);
50     }
51     /**
52      * PopupMenuBean.firePropertyChange method comment.
53      */

54     public void firePropertyChange(java.lang.String JavaDoc propertyName, java.lang.Object JavaDoc oldValue, java.lang.Object JavaDoc newValue) {
55     propertyChange.firePropertyChange(propertyName, oldValue, newValue);
56     }
57     /**
58      * Gets the ownerComponent property (java.awt.Component) value.
59      * @return The ownerComponent property value.
60      * @see #setOwnerComponent
61      */

62     public java.awt.Component JavaDoc getOwnerComponent() {
63     /* Returns the ownerComponent property value. */
64     return fieldOwnerComponent;
65     }
66     /**
67      * Called whenever the part throws an exception.
68      * @param exception java.lang.Throwable
69      */

70     private void handleException(Throwable JavaDoc exception) {
71
72     /* Uncomment the following lines to print uncaught exceptions to stdout */
73     // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
74
// exception.printStackTrace(System.out);
75
}
76     /**
77      * Initialize the class.
78      */

79     /* WARNING: THIS METHOD WILL BE REGENERATED. */
80     private void initialize() {
81     // user code begin {1}
82
// user code end
83
// user code begin {2}
84
// user code end
85
}
86     /**
87      * main entrypoint - starts the part when it is run as an application
88      * @param args java.lang.String[]
89      */

90     public static void main(java.lang.String JavaDoc[] args) {
91     try {
92             org.jacorb.poa.gui.beans.ExtendedPopupMenu aExtendedPopupMenu =
93                 new org.jacorb.poa.gui.beans.ExtendedPopupMenu();
94     } catch (Throwable JavaDoc exception) {
95             System.err.println("Exception occurred in main() of hyperocm.beans.PopupMenu");
96             exception.printStackTrace(System.out);
97     }
98     }
99     /**
100      * PopupMenuBean.removePropertyChangeListener method comment.
101      */

102     public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener JavaDoc listener) {
103     propertyChange.removePropertyChangeListener(listener);
104     }
105     /**
106      * Sets the ownerComponent property (java.awt.Component) value.
107      * @param ownerComponent The new value for the property.
108      * @see #getOwnerComponent
109      */

110     public void setOwnerComponent(java.awt.Component JavaDoc ownerComponent) {
111     /* Get the old property value for fire property change event. */
112     java.awt.Component JavaDoc oldValue = fieldOwnerComponent;
113     /* Set the ownerComponent property (attribute) to the new value. */
114     fieldOwnerComponent = ownerComponent;
115     /* Fire (signal/notify) the ownerComponent property change event. */
116     firePropertyChange("ownerComponent", oldValue, ownerComponent);
117     return;
118     }
119     /**
120      * Performs the show method.
121      * @param mouseEvent java.awt.event.MouseEvent
122      */

123     public void show(java.awt.event.MouseEvent JavaDoc mouseEvent) {
124     /* Perform the show method. */
125     if (mouseEvent != null && mouseEvent.isPopupTrigger())
126     {
127             java.awt.Component JavaDoc popupOwner = mouseEvent.getComponent();
128             if (popupOwner != null)
129             {
130                 setOwnerComponent(popupOwner);
131                 popupOwner.add(this);
132                 show(popupOwner, mouseEvent.getX(), mouseEvent.getY());
133             }
134     }
135     }
136     /**
137      * Performs the show method.
138      * @param mouseEvent java.awt.event.MouseEvent
139      */

140     public void showCertainly(java.awt.event.MouseEvent JavaDoc mouseEvent) {
141     /* Perform the showCertainly method. */
142         java.awt.Component JavaDoc popupOwner = mouseEvent.getComponent();
143         if (popupOwner != null)
144         {
145             setOwnerComponent(popupOwner);
146             popupOwner.add(this);
147             show(popupOwner, mouseEvent.getX(), mouseEvent.getY());
148         }
149     }
150
151 }
152
153
154
155
156
157
158
159
160
161
162
163
164
Popular Tags