I have a JScrollPane with a View. I'm doing a chat application , it's why i need to have my ScrollBar to the Maximum(). To get the right Maximum of the View i have to validate before. When I validate my ScrollPane an automatic repaint is doing. I don't want this repaint because it makes a double repaint when i set the ScrollBar to the Maximum : when the ScrollBar is at the top and a another when it is a the bottom.

my code :

Main.getWindow().getMainPanel().getScrollPaneCenter().validate();
scrollPaneCenter.getVerticalScrollBar().setValue(scrollPaneCenter.getVerticalScrollBar().getMaximum());

PS : I want to disable the repaint of my conponent or maybe you have a solution to have a reversed JScrollPane( to always have the ScrollBar to Bottom) .

有帮助吗?

解决方案

I'm doing a chat application

I'm guessing your are using a a JTextArea or JTextPane.

it's why i need to have my ScrollBar to the Maximum().

You don't need to validate or set the scrollbar manually. You juat append the text to the bottom of the Document. See Text Area Scrolling for a couple of solutions.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top