public abstract class AbstractCompletion extends java.lang.Object implements Completion
Completion
implementations can extend this class. It remembers the
CompletionProvider that returns this completion, and also implements
Comparable, allowing such completions to be compared
lexicographically (ignoring case).
This implementation assumes the input text and replacement text are the
same value. It also returns the input text from its toString()
method (which is what DefaultListCellRenderer
uses to render
objects). Subclasses that wish to override any of this behavior can simply
override the corresponding method(s) needed to do so.
构造器和说明 |
---|
AbstractCompletion(CompletionProvider provider)
Constructor.
|
限定符和类型 | 方法和说明 |
---|---|
int |
compareTo(Completion c2)
Compares this completion to another one lexicographically, ignoring
case.
|
java.lang.String |
getAlreadyEntered(javax.swing.text.JTextComponent comp)
Returns the portion of this completion that has already been entered
into the text component.
|
javax.swing.Icon |
getIcon()
The default implementation returns
null . |
java.lang.String |
getInputText()
Returns the text the user has to (start) typing for this completion
to be offered.
|
CompletionProvider |
getProvider()
Returns the provider that returned this completion.
|
int |
getRelevance()
Returns the "relevance" of this completion.
|
java.lang.String |
getToolTipText()
The default implementation returns
null . |
void |
setRelevance(int relevance)
Sets the relevance of this completion.
|
java.lang.String |
toString()
Returns a string representation of this completion.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getReplacementText, getSummary
public AbstractCompletion(CompletionProvider provider)
provider
- The provider that created this completion.public int compareTo(Completion c2)
compareTo
在接口中 Completion
compareTo
在接口中 java.lang.Comparable<Completion>
c2
- Another completion instance.public java.lang.String getAlreadyEntered(javax.swing.text.JTextComponent comp)
This is a convenience method for:
getProvider().getAlreadyEnteredText(comp)
.
getAlreadyEntered
在接口中 Completion
comp
- The text component.public javax.swing.Icon getIcon()
null
. Subclasses
who wish to display an icon can override this method.getIcon
在接口中 Completion
public java.lang.String getInputText()
Completion.getReplacementText()
.getInputText
在接口中 Completion
Completion.getReplacementText()
public CompletionProvider getProvider()
getProvider
在接口中 Completion
public int getRelevance()
By default, all completions have a relevance of 0
. The
higher the value returned by this method, the higher up in the list
this completion will be; the lower the value returned, the lower it will
be. Completion
s with equal relevance values will be
sorted alphabetically.
getRelevance
在接口中 Completion
public java.lang.String getToolTipText()
null
. Subclasses
can override this method.getToolTipText
在接口中 Completion
public void setRelevance(int relevance)
relevance
- The new relevance of this completion.getRelevance()
public java.lang.String toString()
getInputText()
.toString
在类中 java.lang.Object