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


Java TextComponentPeer.setText方法代码示例

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


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

示例1: setText

import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
 * Sets the text that is presented by this
 * text component to be the specified text.
 * @param       t   the new text;
 *                  if this parameter is {@code null} then
 *                  the text is set to the empty string ""
 * @see         java.awt.TextComponent#getText
 */
public synchronized void setText(String t) {
    if (t == null) {
        t = "";
    }
    TextComponentPeer peer = (TextComponentPeer)this.peer;
    if (peer != null) {
        text = peer.getText();
        // Please note that we do not want to post an event
        // if TextArea.setText() or TextField.setText() replaces text
        // by same text, that is, if component's text remains unchanged.
        if (!t.equals(text)) {
            text = t;
            peer.setText(text);
        }
    } else {
        text = t;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:TextComponent.java

示例2: setText

import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
 * Sets the text that is presented by this
 * text component to be the specified text.
 * @param       t   the new text;
 *                  if this parameter is <code>null</code> then
 *                  the text is set to the empty string ""
 * @see         java.awt.TextComponent#getText
 */
public synchronized void setText(String t) {
    boolean skipTextEvent = (text == null || text.isEmpty())
            && (t == null || t.isEmpty());
    text = (t != null) ? t : "";
    TextComponentPeer peer = (TextComponentPeer)this.peer;
    // Please note that we do not want to post an event
    // if TextArea.setText() or TextField.setText() replaces an empty text
    // by an empty text, that is, if component's text remains unchanged.
    if (peer != null && !skipTextEvent) {
        peer.setText(text);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:TextComponent.java

示例3: setText

import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
 * Sets the text in this component to the specified string.
 *
 * @param text The new text for this component.
 */
public synchronized void setText(String text)
{
  if (text == null)
    text = "";

  this.text = text;

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

示例4: setText

import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
    * Sets the text that is presented by this 
    * text component to be the specified text. 
    * @param       t   the new text;
    *                  if this parameter is <code>null</code> then
    *                  the text is set to the empty string ""
    * @see         java.awt.TextComponent#getText  
    */
   public synchronized void setText(String t) {
text = (t != null) ? t : "";
TextComponentPeer peer = (TextComponentPeer)this.peer;
if (peer != null) {
    peer.setText(text);
}
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:16,代码来源:TextComponent.java

示例5: setText

import java.awt.peer.TextComponentPeer; //导入方法依赖的package包/类
/**
 * Sets the text that is presented by this
 * text component to be the specified text.
 * @param       t   the new text;
 *                  if this parameter is <code>null</code> then
 *                  the text is set to the empty string ""
 * @see         java.awt.TextComponent#getText
 */
public synchronized void setText(String t) {
    text = (t != null) ? t : "";
    TextComponentPeer peer = (TextComponentPeer)this.peer;
    if (peer != null) {
        peer.setText(text);
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:16,代码来源:TextComponent.java


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