posicionamiento bidireccional del cursor
¿Cómo puedo colocar el cursor en un JTextArea indicando la fila y la columna concretas en que deseo que se posicione?
El cursor se llama Caret
puedes colocarlo con el metodo "setCaretPosition(int i)" pero solo si hay texto escrito.
prueba con esto:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Tester extends JFrame {
JTextArea texto;
public Tester() {
texto = new JTextArea();
texto.setText(" " +
" " +
" " +
" ");
texto.setCaretPosition(20);
setDefaultCloseOperation(EXIT_ON_CLOSE);
getContentPane().add(texto);
pack();
}
public static void main(String args[]) {
new Tester().setVisible(true);
}
}
puedes colocarlo con el metodo "setCaretPosition(int i)" pero solo si hay texto escrito.
prueba con esto:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Tester extends JFrame {
JTextArea texto;
public Tester() {
texto = new JTextArea();
texto.setText(" " +
" " +
" " +
" ");
texto.setCaretPosition(20);
setDefaultCloseOperation(EXIT_ON_CLOSE);
getContentPane().add(texto);
pack();
}
public static void main(String args[]) {
new Tester().setVisible(true);
}
}
