public final class CompletionUtilities extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CompletionUtilities.CompletionItemBuilder
Builder for simple
CompletionItem instances. |
static class |
CompletionUtilities.OnSelectContext
A parameter passed to CompletionItemBuilder's onSelect callback.
|
Modifier and Type | Method and Description |
---|---|
static int |
getPreferredWidth(String leftHtmlText,
String rightHtmlText,
Graphics g,
Font defaultFont)
Get preferred width of the item by knowing its left and right html texts.
|
static CompletionUtilities.CompletionItemBuilder |
newCompletionItemBuilder(String insertText)
Creates a builder for simple
CompletionItem instances. |
static void |
renderHtml(ImageIcon icon,
String leftHtmlText,
String rightHtmlText,
Graphics g,
Font defaultFont,
Color defaultColor,
int width,
int height,
boolean selected)
Render a completion item using the provided icon and left and right
html texts.
|
public static int getPreferredWidth(String leftHtmlText, String rightHtmlText, Graphics g, Font defaultFont)
leftHtmlText
- html text displayed on the left side of the item
next to the icon. It may be null which means no left text will be displayed.rightHtmlText
- html text aligned on the right edge of the item's
rendering area. It may be null which means no right text will be displayed.public static void renderHtml(ImageIcon icon, String leftHtmlText, String rightHtmlText, Graphics g, Font defaultFont, Color defaultColor, int width, int height, boolean selected)
icon
- icon 16x16 that will be displayed on the left. It may be null
which means that no icon will be displayed but the space for the icon
will still be reserved (to properly align with other items
that will provide an icon).leftHtmlText
- html text that will be displayed on the left side
of the item's rendering area next to the icon.
rightHtmlText
- html text that will be aligned to the right edge
of the item's rendering area.
g
- non-null graphics through which the rendering happens.defaultFont
- non-null default font to be used for rendering.defaultColor
- non-null default color to be used for rendering.width
- >=0 available width for rendering.height
- >=0 available height for rendering.selected
- whether the item being rendered is currently selected
in the completion's JList. If selected the foreground color is forced
to be black for all parts of the rendered strings.public static CompletionUtilities.CompletionItemBuilder newCompletionItemBuilder(String insertText)
CompletionItem
instances.insertText
- a text to be inserted into a document when selecting the item.