I have a Scrollable-VBox with a lot of TextFields in it. I can TAB-Browse from one TextField to the next. When I reach the last currently visible and press TAB again, the scrollpane switches to the next "page" and the cursor is in the new uppermost Textfield.
But I need a line-by-line scrolling behaviour while jumping from Text-Field to the next at the bottom of the visible area.
Anybody with an idea.
package test;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Scroller extends Application {
@Override
public void start(Stage primaryStage) {
VBox vb = new VBox();
for (int i = 0; i < 360; i++) {
TextField x = new TextField(String.valueOf(i));
vb.getChildren().add(x);
}
ScrollPane sp = new ScrollPane(vb);
sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
sp.setFitToWidth(true);
TextField tf = new TextField();
HBox root = new HBox();
root.getChildren().addAll(sp, tf);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}