Java JTextComponent Caret setTextAndResetCaret(JTextComponent component, String text)

Here you can find the source of setTextAndResetCaret(JTextComponent component, String text)

Description

set Text And Reset Caret

License

Open Source License

Declaration

public static void setTextAndResetCaret(JTextComponent component,
            String text) 

Method Source Code

//package com.java2s;
/*/*from   www  . j  a  va  2  s.  c o m*/
 * SK's Minecraft Launcher
 * Copyright (C) 2010-2014 Albert Pham <http://www.sk89q.com> and contributors
 * Please see LICENSE.txt for license information.
 */

import javax.swing.text.JTextComponent;

public class Main {
    public static void setTextAndResetCaret(JTextComponent component,
            String text) {
        component.setText(text);
        component.setCaretPosition(0);
    }
}

Related

  1. getCaretRow(int idx, JTextComponent comp)
  2. getLineAtCaret(final JTextComponent component)
  3. makeCaretAlwaysVisible(final JTextComponent comp)
  4. selectLineAtCaret(JTextComponent editor)
  5. setCaretUpdateEnabled(JTextComponent comp, boolean updateEnabled)