当前位置: 首页>>代码示例>>Java>>正文


Java TextComponentPeer.setCaretPosition方法代码示例

本文整理汇总了Java中java.awt.peer.TextComponentPeer.setCaretPosition方法的典型用法代码示例。如果您正苦于以下问题:Java TextComponentPeer.setCaretPosition方法的具体用法?Java TextComponentPeer.setCaretPosition怎么用?Java TextComponentPeer.setCaretPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.peer.TextComponentPeer的用法示例。


在下文中一共展示了TextComponentPeer.setCaretPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setCaretPosition

import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
 * Sets 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 passed-in value is greater than this range,
 * the value is set to the last character (or 0 if
 * the <code>TextComponent</code> contains no text)
 * and no error is returned.  If the passed-in value is
 * less than 0, an <code>IllegalArgumentException</code>
 * is thrown.
 *
 * @param        position the position of the text insertion caret
 * @exception    IllegalArgumentException if <code>position</code>
 *               is less than zero
 * @since        JDK1.1
 */
public synchronized void setCaretPosition(int position) {
    if (position < 0) {
        throw new IllegalArgumentException("position less than zero.");
    }

    int maxposition = getText().length();
    if (position > maxposition) {
        position = maxposition;
    }

    TextComponentPeer peer = (TextComponentPeer)this.peer;
    if (peer != null) {
        peer.setCaretPosition(position);
    } else {
        select(position, position);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:TextComponent.java

示例2: setCaretPosition

import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
 * Sets 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 passed-in value is greater than this range,
 * the value is set to the last character (or 0 if
 * the {@code TextComponent} contains no text)
 * and no error is returned.  If the passed-in value is
 * less than 0, an {@code IllegalArgumentException}
 * is thrown.
 *
 * @param        position the position of the text insertion caret
 * @exception    IllegalArgumentException if {@code position}
 *               is less than zero
 * @since        1.1
 */
public synchronized void setCaretPosition(int position) {
    if (position < 0) {
        throw new IllegalArgumentException("position less than zero.");
    }

    int maxposition = getText().length();
    if (position > maxposition) {
        position = maxposition;
    }

    TextComponentPeer peer = (TextComponentPeer)this.peer;
    if (peer != null) {
        peer.setCaretPosition(position);
    } else {
        select(position, position);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:TextComponent.java

示例3: setCaretPosition

import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
    * Sets 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 passed-in value is greater than this range,
    * the value is set to the last character (or 0 if
    * the <code>TextComponent</code> contains no text)
    * and no error is returned.  If the passed-in value is
    * less than 0, an <code>IllegalArgumentException</code>
    * is thrown.
    * 
    * @param        position the position of the text insertion caret
    * @exception    IllegalArgumentException if <code>position</code>
    *               is less than zero
    * @since        JDK1.1
    */
   public synchronized void setCaretPosition(int position) {
if (position < 0) {
    throw new IllegalArgumentException("position less than zero.");
}

int maxposition = getText().length();
if (position > maxposition) {
    position = maxposition;
}

TextComponentPeer peer = (TextComponentPeer)this.peer;
if (peer != null) {
    peer.setCaretPosition(position);
} else {
    select(position, position);
}
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:34,代码来源:TextComponent.java

示例4: setCaretPosition

import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
 * Sets the caret position to the specified value.
 *
 * @param caretPosition The new caret position.
 *
 * @exception IllegalArgumentException If the value supplied for position
 * is less than zero.
 *
 * @since 1.1
 */
public synchronized void setCaretPosition(int caretPosition)
{
  if (caretPosition < 0)
    throw new IllegalArgumentException();

  TextComponentPeer tcp = (TextComponentPeer) getPeer();
  if (tcp != null)
    tcp.setCaretPosition(caretPosition);
}
 
开发者ID:vilie,项目名称:javify,代码行数:20,代码来源:TextComponent.java


注:本文中的java.awt.peer.TextComponentPeer.setCaretPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。