API java : Caret


javax.swing.text
Interface Caret

All Known Implementing Classes:
BasicTextUI.BasicCaret, DefaultCaret

public interface Caret

A place within a document view that represents where things can be inserted into the document model. A caret has a position in the document referred to as a dot. The dot is where the caret is currently located in the model. There is a second position maintained by the caret that represents the other end of a selection called mark. If there is no selection the dot and mark will be equal. If a selection exists, the two values will be different.

The dot can be placed by either calling setDot or moveDot. Setting the dot has the effect of removing any selection that may have previously existed. The dot and mark will be equal. Moving the dot has the effect of creating a selection as the mark is left at whatever position it previously had.


Method Summary
 void addChangeListener(ChangeListener l)
          Adds a listener to track whenever the caret position has been changed.
 void deinstall(JTextComponent c)
          Called when the UI is being removed from the interface of a JTextComponent.
 int getBlinkRate()
          Gets the blink rate of the caret.
 int getDot()
          Fetches the current position of the caret.
 Point getMagicCaretPosition()
          Gets the current caret visual location.
 int getMark()
          Fetches the current position of the mark.
 void install(JTextComponent c)
          Called when the UI is being installed into the interface of a JTextComponent.
 boolean isSelectionVisible()
          Determines if the selection is currently visible.
 boolean isVisible()
          Determines if the caret is currently visible.
 void moveDot(int dot)
          Moves the caret position (dot) to some other position, leaving behind the mark.
 void paint(Graphics g)
          Renders the caret.
 void removeChangeListener(ChangeListener l)
          Removes a listener that was tracking caret position changes.
 void setBlinkRate(int rate)
          Sets the blink rate of the caret.
 void setDot(int dot)
          Sets the caret position to some position.
 void setMagicCaretPosition(Point p)
          Set the current caret visual location.
 void setSelectionVisible(boolean v)
          Sets the visibility of the selection
 void setVisible(boolean v)
          Sets the visibility of the caret.
 

Method Detail

install

void install(JTextComponent c)
Called when the UI is being installed into the interface of a JTextComponent. This can be used to gain access to the model that is being navigated by the implementation of this interface.

Parameters:
c - the JTextComponent

deinstall

void deinstall(JTextComponent c)
Called when the UI is being removed from the interface of a JTextComponent. This is used to unregister any listeners that were attached.

Parameters:
c - the JTextComponent

paint

void paint(Graphics g)
Renders the caret.

Parameters:
g - the graphics context

addChangeListener

void addChangeListener(ChangeListener l)
Adds a listener to track whenever the caret position has been changed.

Parameters:
l - the change listener

removeChangeListener

void removeChangeListener(ChangeListener l)
Removes a listener that was tracking caret position changes.

Parameters:
l - the change listener

isVisible

boolean isVisible()
Determines if the caret is currently visible.

Returns:
true if the caret is visible else false

setVisible

void setVisible(boolean v)
Sets the visibility of the caret.

Parameters:
v - true if the caret should be shown, and false if the caret should be hidden

isSelectionVisible

boolean isSelectionVisible()
Determines if the selection is currently visible.

Returns:
true if the caret is visible else false

setSelectionVisible

void setSelectionVisible(boolean v)
Sets the visibility of the selection

Parameters:
v - true if the caret should be shown, and false if the caret should be hidden

setMagicCaretPosition

void setMagicCaretPosition(Point p)
Set the current caret visual location. This can be used when moving between lines that have uneven end positions (such as when caret up or down actions occur). If text flows left-to-right or right-to-left the x-coordinate will indicate the desired navigation location for vertical movement. If the text flow is top-to-bottom, the y-coordinate will indicate the desired navigation location for horizontal movement.

Parameters:
p - the Point to use for the saved position. This can be null to indicate there is no visual location.

getMagicCaretPosition

Point getMagicCaretPosition()
Gets the current caret visual location.

Returns:
the visual position.
See Also:
setMagicCaretPosition(java.awt.Point)

setBlinkRate

void setBlinkRate(int rate)
Sets the blink rate of the caret. This determines if and how fast the caret blinks, commonly used as one way to attract attention to the caret.

Parameters:
rate - the delay in milliseconds >= 0. If this is zero the caret will not blink.

getBlinkRate

int getBlinkRate()
Gets the blink rate of the caret. This determines if and how fast the caret blinks, commonly used as one way to attract attention to the caret.

Returns:
the delay in milliseconds >= 0. If this is zero the caret will not blink.

getDot

int getDot()
Fetches the current position of the caret.

Returns:
the position >= 0

getMark

int getMark()
Fetches the current position of the mark. If there is a selection, the mark will not be the same as the dot.

Returns:
the position >= 0

setDot

void setDot(int dot)
Sets the caret position to some position. This causes the mark to become the same as the dot, effectively setting the selection range to zero.

Parameters:
dot - the new position to set the caret to >= 0

moveDot

void moveDot(int dot)
Moves the caret position (dot) to some other position, leaving behind the mark. This is useful for making selections.

Parameters:
dot - the new position to move the caret to >= 0

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

7 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-1422
Document créé le 29/08/06 23:05, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-javax/swing/text/Caret.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,61 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
La faculté de citer est un substitut commode à l'intelligence.

Somerset Maugham
 
l'infobrol
Nous sommes le Samedi 02 Juin 2012, 08:41, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)