Class JavaCellRenderer

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, ListCellRenderer<Object>, SwingConstants
Direct Known Subclasses:
JavaParamListCellRenderer

public class JavaCellRenderer extends DefaultListCellRenderer
Cell renderer for Java auto-completion. This renderer attempts to be fast due to the possibility of many (100+) auto-completions dynamically generated for large Java classes. Using Swing's HTML support is simply too slow (see CompletionCellRenderer).

The color scheme for this renderer mimics that found in Eclipse.

Version:
1.0
See Also:
  • Field Details

    • list

      private JList<?> list
    • selected

      private boolean selected
    • evenRow

      private boolean evenRow
    • jsc

      private JavaSourceCompletion jsc
    • altBG

      private static Color altBG
      The alternating background color, or null for none.
    • nonJavaCompletion

      private org.fife.ui.autocomplete.Completion nonJavaCompletion
      This is used instead of jsc for "incomplete" stuff, like classes, interfaces, etc. read from jars (don't yet read the class in, for example).
    • simpleText

      private boolean simpleText
      Whether to not display extra info (type, etc.)in completion text, just the completion's name. The default is false.
  • Constructor Details

    • JavaCellRenderer

      public JavaCellRenderer()
  • Method Details

    • getAlternateBackground

      public static Color getAlternateBackground()
      Returns the background color to use on alternating lines.
      Returns:
      The alternate background color. If this is null, alternating colors are not used.
      See Also:
    • getListCellRendererComponent

      public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean selected, boolean hasFocus)
      Returns the renderer.
      Specified by:
      getListCellRendererComponent in interface ListCellRenderer<Object>
      Overrides:
      getListCellRendererComponent in class DefaultListCellRenderer
      Parameters:
      list - The list of choices being rendered.
      value - The Completion being rendered.
      index - The index into list being rendered.
      selected - Whether the item is selected.
      hasFocus - Whether the item has focus.
    • paintComponent

      protected void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent
    • setAlternateBackground

      public static void setAlternateBackground(Color altBG)
      Sets the background color to use on alternating lines.
      Parameters:
      altBG - The new alternate background color. If this is null, alternating lines will not use different background colors.
      See Also:
    • setSimpleText

      public void setSimpleText(boolean simple)
      Sets whether to display "simple" text about the completion - just the name, no type information, etc. The default value is false.
      Parameters:
      simple - Whether to display "simple" text about the completion.