My code for JScrollPane are as follow :-
JScrollPane sp = new JScrollPane (textArea,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
The issue I have is that when i run the program the scroll bar always starts from the right end which is the ending of the sentence.
@sasikumar's answer is correct. It just needs a small adaption in order to be sure that the JScrollBar
will get its value changed. Try to call it like that:
SwingUtilities.invokeLater(() -> {
JScrollBar horizontalScrollBar = sp.getHorizontalScrollBar();
horizontalScrollBar.setValue(horizontalScrollBar.getMinimum());
});