I have made a ScrollPane
which contains a TextArea
. When the TextArea
gets additional text with the push()
method, the scroll bar needs to be set to the bottom. However, when push()
is used, the bar sets to the top instead. I am not sure what methods are needed to set it to the bottom.
Here is the ScrollPane
code:
package Games.UI.RPG;
import Games.Other.Constants;
import javafx.event.EventHandler;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.input.ScrollEvent;
/**
* Scrollable window which contains Text messages.
*/
class LogPane extends ScrollPane{
private TextArea log;
LogPane(){
initialize();
}
private void initialize(){
log = new TextArea();
log.setEditable(false);
log.prefWidth(512);
log.setText("Text Log loaded. Messages:");
setContent(log);
setFitToWidth(true);
setFitToHeight(true);
setMinHeight(Constants.height);
setMaxHeight(Constants.height);
setMinWidth(Constants.width / 3);
setMaxWidth(Constants.width / 3);
}
public void push(String message){
log.setText(log.getText() + "\n" + message);
setVvalue(getVmax());
}
}