本文整理汇总了Java中java.awt.peer.TextComponentPeer.getCaretPosition方法的典型用法代码示例。如果您正苦于以下问题:Java TextComponentPeer.getCaretPosition方法的具体用法?Java TextComponentPeer.getCaretPosition怎么用?Java TextComponentPeer.getCaretPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.peer.TextComponentPeer
的用法示例。
在下文中一共展示了TextComponentPeer.getCaretPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCaretPosition
import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
* Returns the position of the text insertion caret.
* The caret position is constrained to be between 0
* and the last character of the text, inclusive.
* If the text or caret have not been set, the default
* caret position is 0.
*
* @return the position of the text insertion caret
* @see #setCaretPosition(int)
* @since JDK1.1
*/
public synchronized int getCaretPosition() {
TextComponentPeer peer = (TextComponentPeer)this.peer;
int position = 0;
if (peer != null) {
position = peer.getCaretPosition();
} else {
position = selectionStart;
}
int maxposition = getText().length();
if (position > maxposition) {
position = maxposition;
}
return position;
}
示例2: getCaretPosition
import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
* Returns the position of the text insertion caret.
* The caret position is constrained to be between 0
* and the last character of the text, inclusive.
* If the text or caret have not been set, the default
* caret position is 0.
*
* @return the position of the text insertion caret
* @see #setCaretPosition(int)
* @since 1.1
*/
public synchronized int getCaretPosition() {
TextComponentPeer peer = (TextComponentPeer)this.peer;
int position = 0;
if (peer != null) {
position = peer.getCaretPosition();
} else {
position = selectionStart;
}
int maxposition = getText().length();
if (position > maxposition) {
position = maxposition;
}
return position;
}
示例3: getCaretPosition
import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
* Returns the position of the text insertion caret.
* The caret position is constrained to be between 0
* and the last character of the text, inclusive.
* If the text or caret have not been set, the default
* caret position is 0.
*
* @return the position of the text insertion caret
* @see #setCaretPosition(int)
* @since JDK1.1
*/
public synchronized int getCaretPosition() {
TextComponentPeer peer = (TextComponentPeer)this.peer;
int position = 0;
if (peer != null) {
position = peer.getCaretPosition();
} else {
position = selectionStart;
}
int maxposition = getText().length();
if (position > maxposition) {
position = maxposition;
}
return position;
}
示例4: getCaretPosition
import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
* Returns the current caret position in the text.
*
* @return The caret position in the text.
*/
public synchronized int getCaretPosition()
{
TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
return(tcp.getCaretPosition());
else
return(0);
}