lapisx.swing
Class DelayedPopupMenu

java.lang.Object
  extended bylapisx.swing.DelayedPopupMenu

public class DelayedPopupMenu
extends Object

A popup menu that appears only after the mouse is held down for a certain period of time.


Constructor Summary
DelayedPopupMenu(Component frame, Component trigger, int delay)
          Make a delayed popup menu.
 
Method Summary
 Component getFrame()
          Get the frame in which this menu will popup.
 Component getTrigger()
          Get the component that triggers this menu.
 boolean isVisible()
          Test whether menu is popped up.
protected  JPopupMenu makeMenu()
          Callback that constructs the menu just before showing it.
protected  void showMenu(JPopupMenu menu)
          Callback that shows the menu.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelayedPopupMenu

public DelayedPopupMenu(Component frame,
                        Component trigger,
                        int delay)
Make a delayed popup menu.

Parameters:
frame - Component in which the popup menu will appear (see JPopupMenu.show(java.awt.Component, int, int). This is often a JFrame.
trigger - Component which should trigger the menu.
delay - Delay before showing menu, in milliseconds.
Effects:
Creates a DelayedPopupMenu and attaches a mouse listener to trigger so that when the mouse is pressed down trigger and held for more than delay msec, the menu appears.
Method Detail

isVisible

public boolean isVisible()
Test whether menu is popped up.

Returns:
true iff menu is showing

makeMenu

protected JPopupMenu makeMenu()
Callback that constructs the menu just before showing it. Default implementation just creates an empty JPopupMenu. A subclass should override this to populate the menu.

Returns:
menu, or null to prevent popping up the menu

showMenu

protected void showMenu(JPopupMenu menu)
Callback that shows the menu. Default implementation positions the menu just below the trigger that triggered it in the frame passed to the constructor. A subclass can override this for different placement.

Parameters:
menu - Menu about to be shown

getTrigger

public Component getTrigger()
Get the component that triggers this menu.

Returns:
trigger component

getFrame

public Component getFrame()
Get the frame in which this menu will popup.

Returns:
frame component