I am using a JTextPane for a log, and each time I set text which makes the height of the JTextPane higher than the height of the JScrollPane, it is not neccessarily updated.
To make an example, I have used some System.out.println to illustrate:
Sometimes I get a difference between the Before and After sysouts, but sometimes I get a differences between the After sysouts.
Why does the difference occur, and is there something I can do about it ? It is as the JTextPane rests its height to its original height for a short while, and then suddenly expands back to its proper height.
To make an example, I have used some System.out.println to illustrate:
Code:
System.out.println("Before Add text "+textLogArea.getHeight() + " - ScrollPaneheight: " + textScrollPane.getViewport().getHeight());
textLogArea.setText(textLogArea.getText()+newText);
System.out.println("After Add text. "+textPane.getHeight() + " - ScrollPaneheight: " + textScrollPane.getViewport().getHeight());
System.out.println("After Add text. "+textPane.getHeight() + " - ScrollPaneheight: " + textScrollPane.getViewport().getHeight());
System.out.println("After Add text. "+textPane.getHeight() + " - ScrollPaneheight: " + textScrollPane.getViewport().getHeight());
System.out.println("After Add text. "+textPane.getHeight() + " - ScrollPaneheight: " + textScrollPane.getViewport().getHeight());
Sometimes I get a difference between the Before and After sysouts, but sometimes I get a differences between the After sysouts.
Why does the difference occur, and is there something I can do about it ? It is as the JTextPane rests its height to its original height for a short while, and then suddenly expands back to its proper height.
Last edited: