Java Code Examples for java.awt.peer.TextComponentPeer#getCaretPosition()

The following examples show how to use java.awt.peer.TextComponentPeer#getCaretPosition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextComponent.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: TextComponent.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: TextComponent.java    From jdk-1.7-annotated with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source File: TextComponent.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: TextComponent.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 6
Source File: TextComponent.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 7
Source File: TextComponent.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 8
Source File: TextComponent.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 9
Source File: TextComponent.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 10
Source File: TextComponent.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 11
Source File: TextComponent.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 12
Source File: TextComponent.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 13
Source File: TextComponent.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 14
Source File: TextComponent.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 15
Source File: TextComponent.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 16
Source File: TextComponent.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 17
Source File: TextComponent.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 18
Source File: TextComponent.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}