I have following code snippet
query_area = new JTextArea("");
query_scroll_pane = new JScrollPane(query_area);
query_scroll_pane.setSize(1000,80);
query_scroll_pane.setLocation(10,10);
query_panel.add(query_scroll_pane);
which adds my textarea to scrollpane. Now in a method i dynamically set text for the textarea as
sf.query_area.setText("Query "+(sf.query_counter)+sf.query_store[sf.query_counter]);
System.out.println("Position: "+sf.query_scroll_pane.getHorizontalScrollBar().getValue());
Now my query is when longer text is displayed, scrollbars appear but system.out.println prints position of scrollbar as 0 and not some increased value.
Why so ??