List of usage examples for javax.swing JTextPane getCaret
@Transient
public Caret getCaret()
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); panel.setLayout(new BorderLayout()); setContentPane(panel);/*from ww w . ja v a2 s . co m*/ JTextPane textA = new JTextPane(); textA.setName("text"); textA.setContentType("text/html"); DefaultCaret caret = (DefaultCaret) textA.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); JScrollPane filler = new JScrollPane(textA, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); JTextPane textB = new JTextPane(); textB.setName("text" + "_T"); textB.setFont(textA.getFont()); DefaultCaret caret_T = (DefaultCaret) textB.getCaret(); caret_T.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); JScrollPane filler_T = new JScrollPane(textB, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); panel.add(filler, BorderLayout.NORTH); panel.add(filler_T, BorderLayout.CENTER); pack(); }