diff options
author | Sascha Brawer <brawer@dandelis.ch> | 2003-06-25 13:29:39 +0000 |
---|---|---|
committer | Sascha Brawer <brawer@dandelis.ch> | 2003-06-25 13:29:39 +0000 |
commit | d9ac3a52f5eb9e2b27762a7904287bf4d7968a3a (patch) | |
tree | cb9ce4844ff87bb3c1d71df30c8cd95b06cfb96f /javax | |
parent | e86397ad3fa40fa04005dee671b2cf4fe9a4d873 (diff) | |
download | classpath-d9ac3a52f5eb9e2b27762a7904287bf4d7968a3a.tar.gz |
isPopupTrigger, getPopup: New methods.
Diffstat (limited to 'javax')
-rw-r--r-- | javax/swing/plaf/PopupMenuUI.java | 110 |
1 files changed, 75 insertions, 35 deletions
diff --git a/javax/swing/plaf/PopupMenuUI.java b/javax/swing/plaf/PopupMenuUI.java index d1faa78d1..1871b9b79 100644 --- a/javax/swing/plaf/PopupMenuUI.java +++ b/javax/swing/plaf/PopupMenuUI.java @@ -1,5 +1,5 @@ /* PopupMenuUI.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,40 +37,80 @@ exception statement from your version. */ package javax.swing.plaf; -// Imports -import java.awt.event.*; +import java.awt.event.MouseEvent; +import javax.swing.JPopupMenu; +import javax.swing.Popup; +import javax.swing.PopupFactory; + /** - * PopupMenuUI - * @author Andrew Selkirk - * @version 1.0 + * An abstract base class for delegates that implement the pluggable + * look and feel for a <code>JPopupMenu</code>. + * + * @see javax.swing.JPopupMenu + * + * @author Andrew Selkirk (aselkirk@sympatico.ca) + * @author Sascha Brawer (brawer@dandelis.ch) */ -public abstract class PopupMenuUI extends ComponentUI { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor PopupMenuUI - */ - public PopupMenuUI() { - // TODO - } // PopupMenuUI() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * isPopupTrigger - * @param event TODO - * @returns boolean - */ - public boolean isPopupTrigger(MouseEvent event) { - return false; // TODO - } // isPopupTrigger() - - -} // PopupMenuUI +public abstract class PopupMenuUI + extends ComponentUI +{ + /** + * Constructs a new <code>PopupMenuUI</code>. + */ + public PopupMenuUI() + { + } + + + /** + * Tests whether or not a mouse event triggers a popup menu. + * + * <p>The default implementation calls + * <code>event.isPopupTrigger()</code>, which checks for the gesture + * that is common for the platform on which the application runs. If + * a look and feel wants to employ non-standard conventions for + * triggering a popup menu, it can override this method. + * + * @param event the event to check. + * + * @return <code>true</code> if the event triggers a popup menu; + * <code>false</code> otherwise. + * + * @since 1.3 + */ + public boolean isPopupTrigger(MouseEvent event) + { + return event.isPopupTrigger(); + } + + + /** + * Creates a <code>Popup</code> for displaying the popup menu. The + * default implementation uses the {@link javax.swing.PopupFactory} + * for retrieving a suitable <code>Popup</code>, but subclasses + * might want to override this method if a LookAndFeel needs special + * Popups. + * + * @param popup the <code>JPopupMenu</code> for whose display + * a <code>Popup</code> is needed. + * + * @param x the horizontal position where the popup will be + * displayed. + * + * @param y the vertical position where the popup will be + * displayed. + * + * @return a <code>Popup</code> for showing and hiding + * the menu. + * + * @since 1.4 + */ + public Popup getPopup(JPopupMenu popup, int x, int y) + { + return PopupFactory.getSharedInstance().getPopup( + /* origin/owner of the popup */ popup.getInvoker(), + /* contents */ popup, + x, y); + } +} |