Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is what I use:</p> <pre><code>DefaultCaret caret = (DefaultCaret) textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); </code></pre> <p>Here's how you implement it:</p> <pre><code>public class Test { public static void createFrame() { EventQueue.invokeLater(new Runnable() { @Override public void run() { JFrame frame = new JFrame("Test"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setOpaque(true); JTextArea textArea = new JTextArea(15, 50); textArea.setWrapStyleWord(true); textArea.setEditable(false); textArea.setFont(Font.getFont(Font.SANS_SERIF)); JScrollPane scroller = new JScrollPane(textArea); scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JPanel inputpanel = new JPanel(); inputpanel.setLayout(new FlowLayout()); JTextField input = new JTextField(20); JButton button = new JButton("Enter"); DefaultCaret caret = (DefaultCaret) textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); panel.add(scroller); inputpanel.add(input); inputpanel.add(button); panel.add(inputpanel); frame.getContentPane().add(BorderLayout.CENTER, panel); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); frame.setResizable(false); input.requestFocus(); } }); } public static void main(String... args) { createFrame(); } } </code></pre> <p>What that should look like:</p> <p><img src="https://i.stack.imgur.com/XQJlb.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload