Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
Nested Class Summary | |
class |
|
static class |
Nested classes/interfaces inherited from class javax.swing.JComponent | |
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container | |
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component | |
Component.AccessibleAWTComponent , Component.BltBufferStrategy , Component.FlipBufferStrategy |
Fields inherited from class javax.swing.JComponent | |
TOOL_TIP_TEXT_KEY , UNDEFINED_CONDITION , WHEN_ANCESTOR_OF_FOCUSED_COMPONENT , WHEN_FOCUSED , WHEN_IN_FOCUSED_WINDOW , accessibleContext , listenerList , ui |
Fields inherited from class java.awt.Component | |
BOTTOM_ALIGNMENT , CENTER_ALIGNMENT , LEFT_ALIGNMENT , RIGHT_ALIGNMENT , TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver | |
ABORT , ALLBITS , ERROR , FRAMEBITS , HEIGHT , PROPERTIES , SOMEBITS , WIDTH |
Constructor Summary | |
|
Method Summary | |
void |
|
void |
|
static Keymap | |
void |
|
void |
|
protected void |
|
AccessibleContext |
|
Action[] |
|
Caret |
|
Color | |
CaretListener[] |
|
int |
|
Color | |
Document | |
boolean | |
char | |
Highlighter | |
InputMethodListener[] |
|
Keymap |
|
static Keymap | |
Insets | |
NavigationFilter | |
Dimension | |
int |
|
boolean | |
boolean | |
int |
|
String |
|
Color | |
Color | |
int |
|
int |
|
String |
|
String |
|
String |
|
TextUI |
|
String |
|
boolean |
|
static void |
|
Rectangle |
|
void |
|
protected String |
|
void |
|
void | |
void |
|
void |
|
static Keymap |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void | |
void |
|
int |
|
void |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final String FOCUS_ACCELERATOR_KEY
- Field Value:
- "focusAcceleratorKey"
public void addCaretListener(CaretListener listener)
Adds aCaretListener
object to this text component.
- Parameters:
listener
- the listener to add
public void addInputMethodListener(InputMethodListener listener)
Adds anInputListener
object to this text component.
- Overrides:
- addInputMethodListener in interface Component
- Parameters:
listener
- the listener to add
public static Keymap addKeymap(String n, Keymap parent)
Create a new Keymap with a specific name and parent, and add the new Keymap to the global keymap table. The name may benull
, in which case the new Keymap will not be added to the global Keymap table. The parent may also benull
, which is harmless.
- Parameters:
n
- The name of the new Keymap, ornull
parent
- The parent of the new Keymap, ornull
- Returns:
- The newly created Keymap
- See Also:
removeKeymap(String)
,getKeymap()
,keymaps
protected void fireCaretUpdate(CaretEvent event)
Notifies all registeredCaretListener
objects that the caret was updated.
- Parameters:
event
- the event to send
public AccessibleContext getAccessibleContext()
Get theAccessibleContext
of this object.
- Specified by:
- getAccessibleContext in interface Accessible
- Overrides:
- getAccessibleContext in interface JComponent
- Returns:
- an
AccessibleContext
object
public Action[] getActions()
Returns the set of available Actions this component's associated editor can run. Equivalent to callinggetUI().getEditorKit().getActions()
. This set of Actions is a reasonable value to provide as a parameter toloadKeymap(Keymap,JTextComponent.KeyBinding[],Action[])
, when resolving a set ofJTextComponent.KeyBinding
objects against this component.
- Returns:
- The set of available Actions on this component's
EditorKit
public Caret getCaret()
TheCaret
object used in this text component.
- Returns:
- the caret object
public CaretListener[] getCaretListeners()
Returns all addedCaretListener
objects.
- Returns:
- an array of listeners
public int getCaretPosition()
Retrisves the current caret position.
- Returns:
- the current position
public InputMethodListener[] getInputMethodListeners()
Returns all addedInputMethodListener
objects.
- Overrides:
- getInputMethodListeners in interface Component
- Returns:
- an array of listeners
public Keymap getKeymap()
Get the current Keymap of this component.
- Returns:
- The component's current Keymap
- See Also:
setKeymap(Keymap)
,keymap
public static Keymap getKeymap(String n)
Get a Keymap from the global keymap table, by name.
- Parameters:
n
- The name of the Keymap to look up
- Returns:
- A Keymap associated with the provided name, or
null
if no such Keymap exists
- See Also:
addKeymap(String,Keymap)
,removeKeymap(String)
,keymaps
public Dimension getPreferredScrollableViewportSize()
- Specified by:
- getPreferredScrollableViewportSize in interface Scrollable
public int getScrollableBlockIncrement(Rectangle visible, int orientation, int direction)
- Specified by:
- getScrollableBlockIncrement in interface Scrollable
public boolean getScrollableTracksViewportHeight()
- Specified by:
- getScrollableTracksViewportHeight in interface Scrollable
public boolean getScrollableTracksViewportWidth()
- Specified by:
- getScrollableTracksViewportWidth in interface Scrollable
public int getScrollableUnitIncrement(Rectangle visible, int orientation, int direction)
- Specified by:
- getScrollableUnitIncrement in interface Scrollable
public String getSelectedText()
Retrieves the currently selected text in this text document.
- Returns:
- the selected text
- Throws:
NullPointerException
- if the underlaying document is null
public int getSelectionEnd()
Returns the end postion of the currently selected text.
- Returns:
- the end postion
public int getSelectionStart()
Returns the start postion of the currently selected text.
- Returns:
- the start postion
public String getText()
Retrieves the current text in this text document.
- Returns:
- the text
- Throws:
NullPointerException
- if the underlaying document is null
public String getText(int offset, int length) throws BadLocationException
Retrieves a part of the current text in this document.
- Parameters:
offset
- the postion of the first characterlength
- the length of the text to retrieve
- Returns:
- the text
- Throws:
BadLocationException
- if arguments do not hold pre-conditions
public String getToolTipText(MouseEvent ev)
Returns the tooltip text for this text component for the given mouse event. This forwards the call toTextUI.getToolTipText(JTextComponent,Point)
.
- Overrides:
- getToolTipText in interface JComponent
- Parameters:
ev
- the mouse event
- Returns:
- the tooltip text for this text component for the given mouse event
public TextUI getUI()
This method returns the label's UI delegate.
- Returns:
- The label's UI delegate.
public String getUIClassID()
Returns a string that specifies the name of the Look and Feel class that renders this component.
- Overrides:
- getUIClassID in interface JComponent
- Returns:
- the string "TextComponentUI"
public boolean isEditable()
Checks whether this text component it editable.
- Returns:
- true if editable, false otherwise
public static void loadKeymap(Keymap map, JTextComponent.KeyBinding[] bindings, Action[] actions)
Resolves a set of bindings against a set of actions and inserts the results into aKeymap
. Specifically, for each provided bindingb
, if there exists a provided actiona
such thata.getValue(Action.NAME) == b.ActionName
then an entry is added to the Keymap mappingb
toa
.
- Parameters:
map
- The Keymap to add new mappings tobindings
- The set of bindings to add to the Keymapactions
- The set of actions to resolve binding names against
public void moveCaretPosition(int position)
Moves the caret to a given position. This selects the text between the old and the new position of the caret.
protected String paramString()
Returns a string representation of this JTextComponent.
- Overrides:
- paramString in interface JComponent
public void read(Reader input, Object streamDescription) throws IOException
Read and set the content this component. If not overridden, the method reads the component content as a plain text. The second parameter of this method describes the input stream. It can be String, URL, File and so on. If not null, this object is added to the properties of the associated document under the keyDocument.StreamDescriptionProperty
.
- Parameters:
input
- an input stream to read from.streamDescription
- an object, describing the stream.
- Throws:
IOException
- if the reader throws it.
- See Also:
getDocument()
,Document.getProperty(Object)
public void removeCaretListener(CaretListener listener)
Removed aCaretListener
object from this text component.
- Parameters:
listener
- the listener to remove
public void removeInputMethodListener(InputMethodListener listener)
Removes anInputListener
object from this text component.
- Overrides:
- removeInputMethodListener in interface Component
- Parameters:
listener
- the listener to remove
public static Keymap removeKeymap(String n)
Remove a Keymap from the global Keymap table, by name.
- Parameters:
n
- The name of the Keymap to remove
- Returns:
- The keymap removed from the global table
- See Also:
addKeymap(String,Keymap)
,getKeymap()
,keymaps
public void select(int start, int end)
Selects a part of the content of the text component.
- Parameters:
start
- the start position of the selected textend
- the end position of the selected text
public void setCaret(Caret newCaret)
Sets a newCaret
for this text component.
- Parameters:
newCaret
- the newCaret
to set
public void setCaretPosition(int position)
Sets the caret to a new position.
- Parameters:
position
- the new position
public void setEditable(boolean newValue)
Enables/disabled this text component's editability.
- Parameters:
newValue
- true to make it editable, false otherwise.
public void setKeymap(Keymap k)
Set the current Keymap of this component, installing appropriateKeymapWrapper
andKeymapActionMap
objects in theInputMap
andActionMap
parent chains, respectively, and fire a property change event with name"keymap"
.
- See Also:
getKeymap()
,keymap
public void setSelectionEnd(int end)
Selects the text from the selection start postion to the given position.
- Parameters:
end
- the end positon of the selected text.
public void setSelectionStart(int start)
Selects the text from the given postion to the selection end position.
- Parameters:
start
- the start positon of the selected text.
public void setUI(TextUI newUI)
This method sets the label's UI delegate.
- Parameters:
newUI
- The label's UI delegate.
public void updateUI()
This method resets the label's UI delegate to the default UI for the current look and feel.
- Overrides:
- updateUI in interface JComponent
public void write(Writer output) throws IOException
Write the content of this component to the given stream. If not overridden, the method writes the component content as a plain text.
- Parameters:
output
- the writer to write into.
- Throws:
IOException
- if the writer throws it.