Module platform

Class AutoCompletePopupWindow

java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
javax.swing.JWindow
de.grogra.pf.ui.autocomplete.impl.AutoCompletePopupWindow
All Implemented Interfaces:
MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CaretListener, ListSelectionListener, RootPaneContainer

public class AutoCompletePopupWindow extends JWindow implements CaretListener, ListSelectionListener, MouseListener
The actual popup window of choices. When visible, this window intercepts certain keystrokes in the parent text component and uses them to navigate the completion choices instead. If Enter or Escape is pressed, the window hides itself and notifies the AbstractAutoCompletor to insert the selected text. Copied and adapted for GroIMP
Version:
1.0
Author:
Robert Futrell
See Also:
  • Method Details

    • caretUpdate

      public void caretUpdate(CaretEvent e)
      Specified by:
      caretUpdate in interface CaretListener
    • doAutocomplete

      protected void doAutocomplete()
    • getDescriptionWindowColor

      public Color getDescriptionWindowColor()
      Returns the background color of the description window.
      Returns:
      The background color, or null if it has not been created yet.
      See Also:
    • getListCellRenderer

      public ListCellRenderer getListCellRenderer()
      Returns the default list cell renderer used when a completion provider does not supply its own.
      Returns:
      The default list cell renderer.
      See Also:
    • getSelection

      public Completion getSelection()
      Returns the selected value, or null if nothing is selected.
      Returns:
      The selected value.
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • setCompletions

      public void setCompletions(List<Completion> completions)
      Sets the completions to display in the choices list. The first completion is selected.
      Parameters:
      completions - The completions to display.
    • setDescriptionWindowSize

      public void setDescriptionWindowSize(Dimension size)
      Sets the size of the description window.
      Parameters:
      size - The new size. This cannot be null.
    • setDescriptionWindowColor

      public void setDescriptionWindowColor(Color color)
      Sets the color of the description window.
      Parameters:
      color - The new color. This cannot be null.
      See Also:
    • setListCellRenderer

      public void setListCellRenderer(ListCellRenderer<Object> renderer)
      Sets the default list cell renderer to use when a completion provider does not supply its own.
      Parameters:
      renderer - The renderer to use. If this is null, a default renderer is used.
      See Also:
    • setLocationRelativeTo

      public void setLocationRelativeTo(Rectangle r)
      Sets the location of this window to be "good" relative to the specified rectangle. That rectangle should be the location of the text component's caret, in screen coordinates.
      Parameters:
      r - The text component's caret position, in screen coordinates.
    • setVisible

      public void setVisible(boolean visible)
      Toggles the visibility of this popup window.
      Overrides:
      setVisible in class Window
      Parameters:
      visible - Whether this window should be visible.
    • updateUI

      public void updateUI()
      Updates the LookAndFeel of this window and the description window.
    • valueChanged

      public void valueChanged(ListSelectionEvent e)
      Called when a new item is selected in the popup list.
      Specified by:
      valueChanged in interface ListSelectionListener
      Parameters:
      e - The event.