summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gilbert <david.gilbert@object-refinery.com>2006-06-28 12:58:39 +0000
committerDavid Gilbert <david.gilbert@object-refinery.com>2006-06-28 12:58:39 +0000
commitf593f9e0668e33b5ea36e7b6b96fb634cc80cccc (patch)
tree1f97e8520a3853e7faa5181538bd853f08c1b5a0
parent5fcf70a20c4889826eeb0d3b6b7a935f85197000 (diff)
downloadclasspath-f593f9e0668e33b5ea36e7b6b96fb634cc80cccc.tar.gz
2006-06-28 David Gilbert <david.gilbert@object-refinery.com>
* javax/swing/JComponent.java (componentPopupMenu): New field, (inheritsPopupMenu): New field, (getInheritsPopupMenu): Implemented, (setInheritsPopupMenu): Likewise, (getComponentPopupMenu): Likewise, (setComponentPopupMenu): Likewise, * javax/swing/JLabel.java (JLabel(String, Icon, int)): Set inheritsPopupMenu to true.
-rw-r--r--ChangeLog12
-rw-r--r--javax/swing/JComponent.java97
-rw-r--r--javax/swing/JLabel.java1
3 files changed, 110 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 621dd25f8..74bf74682 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-06-28 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JComponent.java
+ (componentPopupMenu): New field,
+ (inheritsPopupMenu): New field,
+ (getInheritsPopupMenu): Implemented,
+ (setInheritsPopupMenu): Likewise,
+ (getComponentPopupMenu): Likewise,
+ (setComponentPopupMenu): Likewise,
+ * javax/swing/JLabel.java
+ (JLabel(String, Icon, int)): Set inheritsPopupMenu to true.
+
2006-06-28 Raif S. Naffah <raif@swiftdsl.com.au>
* gnu/javax/crypto/key/dh/GnuDHPublicKey.java (str): New field.
diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java
index 91b3601bd..11674d56c 100644
--- a/javax/swing/JComponent.java
+++ b/javax/swing/JComponent.java
@@ -572,6 +572,21 @@ public abstract class JComponent extends Container implements Serializable
*/
String toolTipText;
+ /**
+ * The popup menu for the component.
+ *
+ * @see #getComponentPopupMenu()
+ * @see #setComponentPopupMenu(JPopupMenu)
+ */
+ JPopupMenu componentPopupMenu;
+
+ /**
+ * A flag that controls whether the {@link #getComponentPopupMenu()} method
+ * looks to the component's parent when the <code>componentPopupMenu</code>
+ * field is <code>null</code>.
+ */
+ boolean inheritsPopupMenu;
+
/**
* <p>Whether to double buffer this component when painting. This flag
* should generally be <code>true</code>, to ensure good painting
@@ -1524,8 +1539,90 @@ public abstract class JComponent extends Container implements Serializable
{
return getToolTipText();
}
+
+ /**
+ * Returns the flag that controls whether or not the component inherits its
+ * parent's popup menu when no popup menu is specified for this component.
+ *
+ * @return A boolean.
+ *
+ * @since 1.5
+ *
+ * @see #setInheritsPopupMenu(boolean)
+ */
+ public boolean getInheritsPopupMenu()
+ {
+ return inheritsPopupMenu;
+ }
+
+ /**
+ * Sets the flag that controls whether or not the component inherits its
+ * parent's popup menu when no popup menu is specified for this component.
+ * This is a bound property with the property name 'inheritsPopupMenu'.
+ *
+ * @param inherit the new flag value.
+ *
+ * @since 1.5
+ *
+ * @see #getInheritsPopupMenu()
+ */
+ public void setInheritsPopupMenu(boolean inherit)
+ {
+ if (inheritsPopupMenu != inherit)
+ {
+ inheritsPopupMenu = inherit;
+ this.firePropertyChange("inheritsPopupMenu", ! inherit, inherit);
+ }
+ }
+
+ /**
+ * Returns the popup menu for this component. If the popup menu is
+ * <code>null</code> AND the {@link #getInheritsPopupMenu()} method returns
+ * <code>true</code>, this method will return the parent's popup menu (if it
+ * has one).
+ *
+ * @return The popup menu (possibly <code>null</code>.
+ *
+ * @since 1.5
+ *
+ * @see #setComponentPopupMenu(JPopupMenu)
+ * @see #getInheritsPopupMenu()
+ */
+ public JPopupMenu getComponentPopupMenu()
+ {
+ if (componentPopupMenu == null && getInheritsPopupMenu())
+ {
+ Container parent = getParent();
+ if (parent instanceof JComponent)
+ return ((JComponent) parent).getComponentPopupMenu();
+ else
+ return null;
+ }
+ else
+ return componentPopupMenu;
+ }
/**
+ * Sets the popup menu for this component (this is a bound property with
+ * the property name 'componentPopupMenu').
+ *
+ * @param popup the popup menu (<code>null</code> permitted).
+ *
+ * @since 1.5
+ *
+ * @see #getComponentPopupMenu()
+ */
+ public void setComponentPopupMenu(JPopupMenu popup)
+ {
+ if (componentPopupMenu != popup)
+ {
+ JPopupMenu old = componentPopupMenu;
+ componentPopupMenu = popup;
+ firePropertyChange("componentPopupMenu", old, popup);
+ }
+ }
+
+ /**
* Return the top level ancestral container (usually a {@link
* java.awt.Window} or {@link java.applet.Applet}) which this component is
* contained within, or <code>null</code> if no ancestors exist.
diff --git a/javax/swing/JLabel.java b/javax/swing/JLabel.java
index b3daf3bc4..fcf0fd7cb 100644
--- a/javax/swing/JLabel.java
+++ b/javax/swing/JLabel.java
@@ -436,6 +436,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
this.icon = icon;
this.horizontalAlignment = horizontalAlignment;
setAlignmentX(0.0F);
+ setInheritsPopupMenu(true);
updateUI();
}