本文整理汇总了Java中java.awt.peer.TextComponentPeer.select方法的典型用法代码示例。如果您正苦于以下问题:Java TextComponentPeer.select方法的具体用法?Java TextComponentPeer.select怎么用?Java TextComponentPeer.select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.peer.TextComponentPeer
的用法示例。
在下文中一共展示了TextComponentPeer.select方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: select
import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
* This method sets the selected text range to the text between the
* specified start and end positions. Illegal values for these
* positions are silently fixed.
*
* @param selectionStart The new start position for the selected text.
* @param selectionEnd The new end position for the selected text.
*/
public synchronized void select(int selectionStart, int selectionEnd)
{
if (selectionStart < 0)
selectionStart = 0;
if (selectionStart > getText().length())
selectionStart = text.length();
if (selectionEnd > text.length())
selectionEnd = text.length();
if (selectionStart > selectionEnd)
selectionStart = selectionEnd;
this.selectionStart = selectionStart;
this.selectionEnd = selectionEnd;
TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
tcp.select(selectionStart, selectionEnd);
}
示例2: select
import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
* This method sets the selected text range to the text between the
* specified start and end positions. Illegal values for these
* positions are silently fixed.
*
* @param selectionStart The new start position for the selected text.
* @param selectionEnd The new end position for the selected text.
*/
public synchronized void select(int selectionStart, int selectionEnd)
{
if (selectionStart < 0)
selectionStart = 0;
if (selectionStart > getText().length())
selectionStart = text.length();
if (selectionEnd > text.length())
selectionEnd = text.length();
if (selectionStart > selectionEnd)
selectionStart = selectionEnd;
this.selectionStart = selectionStart;
this.selectionEnd = selectionEnd;
TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
tcp.select(selectionStart, selectionEnd);
}
示例3: selectAll
import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
* Selects all the text in this text component.
* @see java.awt.TextComponent#select
*/
public synchronized void selectAll() {
this.selectionStart = 0;
this.selectionEnd = getText().length();
TextComponentPeer peer = (TextComponentPeer)this.peer;
if (peer != null) {
peer.select(selectionStart, selectionEnd);
}
}
示例4: selectAll
import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
* Selects all the text in this text component.
* @see java.awt.TextComponent#select
*/
public synchronized void selectAll() {
String text = getText();
this.selectionStart = 0;
this.selectionEnd = getText().length();
TextComponentPeer peer = (TextComponentPeer)this.peer;
if (peer != null) {
peer.select(selectionStart, selectionEnd);
}
}
示例5: character
import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
* Selects the text between the specified start and end positions.
* <p>
* This method sets the start and end positions of the
* selected text, enforcing the restriction that the start position
* must be greater than or equal to zero. The end position must be
* greater than or equal to the start position, and less than or
* equal to the length of the text component's text. The
* character positions are indexed starting with zero.
* The length of the selection is
* <code>endPosition</code> - <code>startPosition</code>, so the
* character at <code>endPosition</code> is not selected.
* If the start and end positions of the selected text are equal,
* all text is deselected.
* <p>
* If the caller supplies values that are inconsistent or out of
* bounds, the method enforces these constraints silently, and
* without failure. Specifically, if the start position or end
* position is greater than the length of the text, it is reset to
* equal the text length. If the start position is less than zero,
* it is reset to zero, and if the end position is less than the
* start position, it is reset to the start position.
*
* @param selectionStart the zero-based index of the first
character (<code>char</code> value) to be selected
* @param selectionEnd the zero-based end position of the
text to be selected; the character (<code>char</code> value) at
<code>selectionEnd</code> is not selected
* @see java.awt.TextComponent#setSelectionStart
* @see java.awt.TextComponent#setSelectionEnd
* @see java.awt.TextComponent#selectAll
*/
public synchronized void select(int selectionStart, int selectionEnd) {
String text = getText();
if (selectionStart < 0) {
selectionStart = 0;
}
if (selectionStart > text.length()) {
selectionStart = text.length();
}
if (selectionEnd > text.length()) {
selectionEnd = text.length();
}
if (selectionEnd < selectionStart) {
selectionEnd = selectionStart;
}
this.selectionStart = selectionStart;
this.selectionEnd = selectionEnd;
TextComponentPeer peer = (TextComponentPeer)this.peer;
if (peer != null) {
peer.select(selectionStart, selectionEnd);
}
}
示例6: select
import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
* Selects the text between the specified start and end positions.
* <p>
* This method sets the start and end positions of the
* selected text, enforcing the restriction that the start position
* must be greater than or equal to zero. The end position must be
* greater than or equal to the start position, and less than or
* equal to the length of the text component's text. The
* character positions are indexed starting with zero.
* The length of the selection is
* {@code endPosition} - {@code startPosition}, so the
* character at {@code endPosition} is not selected.
* If the start and end positions of the selected text are equal,
* all text is deselected.
* <p>
* If the caller supplies values that are inconsistent or out of
* bounds, the method enforces these constraints silently, and
* without failure. Specifically, if the start position or end
* position is greater than the length of the text, it is reset to
* equal the text length. If the start position is less than zero,
* it is reset to zero, and if the end position is less than the
* start position, it is reset to the start position.
*
* @param selectionStart the zero-based index of the first
* character ({@code char} value) to be selected
* @param selectionEnd the zero-based end position of the
* text to be selected; the character ({@code char} value) at
* {@code selectionEnd} is not selected
* @see java.awt.TextComponent#setSelectionStart
* @see java.awt.TextComponent#setSelectionEnd
* @see java.awt.TextComponent#selectAll
*/
public synchronized void select(int selectionStart, int selectionEnd) {
String text = getText();
if (selectionStart < 0) {
selectionStart = 0;
}
if (selectionStart > text.length()) {
selectionStart = text.length();
}
if (selectionEnd > text.length()) {
selectionEnd = text.length();
}
if (selectionEnd < selectionStart) {
selectionEnd = selectionStart;
}
this.selectionStart = selectionStart;
this.selectionEnd = selectionEnd;
TextComponentPeer peer = (TextComponentPeer)this.peer;
if (peer != null) {
peer.select(selectionStart, selectionEnd);
}
}
示例7: character
import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
* Selects the text between the specified start and end positions.
* <p>
* This method sets the start and end positions of the
* selected text, enforcing the restriction that the start position
* must be greater than or equal to zero. The end position must be
* greater than or equal to the start position, and less than or
* equal to the length of the text component's text. The
* character positions are indexed starting with zero.
* The length of the selection is
* <code>endPosition</code> - <code>startPosition</code>, so the
* character at <code>endPosition</code> is not selected.
* If the start and end positions of the selected text are equal,
* all text is deselected.
* <p>
* If the caller supplies values that are inconsistent or out of
* bounds, the method enforces these constraints silently, and
* without failure. Specifically, if the start position or end
* position is greater than the length of the text, it is reset to
* equal the text length. If the start position is less than zero,
* it is reset to zero, and if the end position is less than the
* start position, it is reset to the start position.
*
* @param selectionStart the zero-based index of the first
character (<code>char</code> value) to be selected
* @param selectionEnd the zero-based end position of the
text to be selected; the character (<code>char</code> value) at
<code>selectionEnd</code> is not selected
* @see java.awt.TextComponent#setSelectionStart
* @see java.awt.TextComponent#setSelectionEnd
* @see java.awt.TextComponent#selectAll
*/
public synchronized void select(int selectionStart, int selectionEnd) {
String text = getText();
if (selectionStart < 0) {
selectionStart = 0;
}
if (selectionStart > text.length()) {
selectionStart = text.length();
}
if (selectionEnd > text.length()) {
selectionEnd = text.length();
}
if (selectionEnd < selectionStart) {
selectionEnd = selectionStart;
}
this.selectionStart = selectionStart;
this.selectionEnd = selectionEnd;
TextComponentPeer peer = (TextComponentPeer)this.peer;
if (peer != null) {
peer.select(selectionStart, selectionEnd);
}
}