站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

PopupManager (Editor Library) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.lib/1 1.14.0 3

org.netbeans.editor
Class PopupManager

java.lang.Object
  extended by org.netbeans.editor.PopupManager

public class PopupManager
extends Object

Popup manager allows to display an arbitrary popup component over the underlying text component.

Since:
03/2002

Nested Class Summary
static class PopupManager.HorizontalBounds
          Horizontal bounds of popup panel specification
static class PopupManager.Placement
          Placement of popup panel specification
 
Field Summary
static PopupManager.Placement Above
          Place popup always above cursor
static PopupManager.Placement AbovePreferred
          Place popup above cursor.
static PopupManager.Placement Below
          Place popup always below cursor
static PopupManager.Placement BelowPreferred
          Place popup below cursor.
static PopupManager.Placement Largest
          Place popup to larger area.
static PopupManager.HorizontalBounds ScrollBarBounds
          Place popup inside the whole scrollbar
static PopupManager.HorizontalBounds ViewPortBounds
          Place popup inside the scrollbar's viewport
 
Constructor Summary
PopupManager(JTextComponent textComponent)
          Creates a new instance of PopupManager
 
Method Summary
protected static Rectangle computeBounds(JComponent popup, int viewWidth, int viewHeight, Rectangle cursorBounds, PopupManager.Placement placement)
           
protected static Rectangle computeBounds(JComponent popup, int viewWidth, int viewHeight, Rectangle cursorBounds, PopupManager.Placement placement, PopupManager.HorizontalBounds horizontalBounds)
          Computes a best-fit bounds of popup panel according to available space in the underlying view (visible part of the pane).
protected static Rectangle computeBounds(JComponent popup, JComponent view, Rectangle cursorBounds, PopupManager.Placement placement)
           
protected static Rectangle computeBounds(JComponent popup, JComponent view, Rectangle cursorBounds, PopupManager.Placement placement, PopupManager.HorizontalBounds horizontalBounds)
          Variation of the method for computing the bounds for the concrete view component.
 JComponent get()
          Returns installed popup panel component
 void install(JComponent popup)
          Install popup component to textComponent root pane based on caret coordinates with the Largest placement.
 void install(JComponent popup, Rectangle cursorBounds, PopupManager.Placement placement)
           
 void install(JComponent popup, Rectangle cursorBounds, PopupManager.Placement placement, PopupManager.HorizontalBounds horizontalBounds)
           
 void install(JComponent popup, Rectangle cursorBounds, PopupManager.Placement placement, PopupManager.HorizontalBounds horizontalBounds, int horizontalAdjustment, int verticalAdjustment)
           
 void uninstall(JComponent popup)
          Removes popup component from textComponent root pane
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Above

public static final PopupManager.Placement Above
Place popup always above cursor


Below

public static final PopupManager.Placement Below
Place popup always below cursor


Largest

public static final PopupManager.Placement Largest
Place popup to larger area. i.e. if place below cursor is larger than place above, then popup will be placed below cursor.


AbovePreferred

public static final PopupManager.Placement AbovePreferred
Place popup above cursor. If a place above cursor is insufficient, then popup will be placed below cursor.


BelowPreferred

public static final PopupManager.Placement BelowPreferred
Place popup below cursor. If a place below cursor is insufficient, then popup will be placed above cursor.


ViewPortBounds

public static final PopupManager.HorizontalBounds ViewPortBounds
Place popup inside the scrollbar's viewport


ScrollBarBounds

public static final PopupManager.HorizontalBounds ScrollBarBounds
Place popup inside the whole scrollbar

Constructor Detail

PopupManager

public PopupManager(JTextComponent textComponent)
Creates a new instance of PopupManager

Method Detail

install

public void install(JComponent popup)
Install popup component to textComponent root pane based on caret coordinates with the Largest placement. Note: Make sure the component is properly uninstalled later, if it is not necessary. See issue #35325 for details.

Parameters:
popup - popup component to be installed into root pane of the text component.

uninstall

public void uninstall(JComponent popup)
Removes popup component from textComponent root pane

Parameters:
popup - popup component to be removed from root pane of the text component.

install

public void install(JComponent popup,
                    Rectangle cursorBounds,
                    PopupManager.Placement placement,
                    PopupManager.HorizontalBounds horizontalBounds,
                    int horizontalAdjustment,
                    int verticalAdjustment)

install

public void install(JComponent popup,
                    Rectangle cursorBounds,
                    PopupManager.Placement placement,
                    PopupManager.HorizontalBounds horizontalBounds)

install

public void install(JComponent popup,
                    Rectangle cursorBounds,
                    PopupManager.Placement placement)

get

public JComponent get()
Returns installed popup panel component


computeBounds

protected static Rectangle computeBounds(JComponent popup,
                                         JComponent view,
                                         Rectangle cursorBounds,
                                         PopupManager.Placement placement,
                                         PopupManager.HorizontalBounds horizontalBounds)
Variation of the method for computing the bounds for the concrete view component. As the component can possibly be placed in a scroll pane it's first necessary to translate the cursor bounds and also translate back the resulting popup bounds.

Parameters:
popup - popup panel to be displayed
view - component over which the popup is displayed.
cursorBounds - the bounds of the caret or mouse cursor relative to the upper-left corner of the visible view.
placement - where to place the popup panel according to the cursor position.
Returns:
bounds of popup panel relative to the upper-left corner of the underlying view component. null if there is no place to display popup.

computeBounds

protected static Rectangle computeBounds(JComponent popup,
                                         JComponent view,
                                         Rectangle cursorBounds,
                                         PopupManager.Placement placement)

computeBounds

protected static Rectangle computeBounds(JComponent popup,
                                         int viewWidth,
                                         int viewHeight,
                                         Rectangle cursorBounds,
                                         PopupManager.Placement placement,
                                         PopupManager.HorizontalBounds horizontalBounds)
Computes a best-fit bounds of popup panel according to available space in the underlying view (visible part of the pane). The placement is first evaluated and put into the popup's client property by popup.putClientProperty(Placement.class, actual-placement). The actual placement is
  • Above if the original placement was Above. Or if the original placement was AbovePreferred or Largest and there is more space above the cursor than below it.
  • Below if the original placement was Below. Or if the original placement was BelowPreferred or Largest and there is more space below the cursor than above it.
  • AbovePreferred if the original placement was AbovePreferred and there is less space above the cursor than below it.
  • BelowPreferred if the original placement was BelowPreferred and there is less space below the cursor than above it.

    Once the placement client property is set the popup.setSize() is called with the size of the area above/below the cursor (indicated by the placement). The popup responds by updating its size to the equal or smaller size. If it cannot physically fit into the requested area it can call putClientProperty(Placement.class, null) on itself to indicate that it cannot fit. The method scans the content of the client property upon return from popup.setSize() and if it finds null there it returns null bounds in that case. The only exception is if the placement was either AbovePreferred or BelowPreferred. In that case the method gives it one more try by attempting to fit the popup into (bigger) complementary Below and Above areas (respectively). The popup either fits into these (bigger) areas or it again responds by returning null in the client property in which case the method finally gives up and returns null bounds.

    Parameters:
    popup - popup panel to be displayed
    viewWidth - width of the visible view area.
    viewHeight - height of the visible view area.
    cursorBounds - the bounds of the caret or mouse cursor relative to the upper-left corner of the visible view
    placement - where to place the popup panel according to the cursor position
    Returns:
    bounds of popup panel relative to the upper-left corner of the underlying view. null if there is no place to display popup.

computeBounds

protected static Rectangle computeBounds(JComponent popup,
                                         int viewWidth,
                                         int viewHeight,
                                         Rectangle cursorBounds,
                                         PopupManager.Placement placement)

org.netbeans.modules.editor.lib/1 1.14.0 3

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.