import javafx.application.*; import javafx.beans.InvalidationListener; import javafx.beans.Observable; import javafx.geometry.*; import javafx.scene.*; import javafx.scene.paint.*; import javafx.scene.layout.*; import javafx.scene.shape.*; import javafx.scene.text.*; import javafx.scene.control.*; import javafx.stage.*; import static javafx.geometry.NodeOrientation.*; public class RT26132 extends Application { public void start(Stage stage) { final VBox vbox = new VBox(10); vbox.setStyle("-fx-padding: 8;"); vbox.setFillWidth(false); vbox.setAlignment(Pos.CENTER); final CheckBox cb = new CheckBox("Set clip"); cb.setSelected(true); vbox.getChildren().add(cb); vbox.getChildren().add(mkSP(LEFT_TO_RIGHT)); vbox.getChildren().add(mkSP(RIGHT_TO_LEFT)); cb.selectedProperty().addListener(new InvalidationListener() { @Override public void invalidated(Observable valueModel) { boolean setClip = cb.isSelected(); for (int i = 1; i <= 2; i++) { ScrollPane sp = (ScrollPane)((HBox)vbox.getChildren().get(i)).getChildren().get(1); StackPane viewRect = (StackPane)sp.getChildrenUnmodifiable().get(0); if (!setClip) { viewRect.getProperties().put("clip", viewRect.getClip()); viewRect.setClip(null); } else { viewRect.setClip((Node)viewRect.getProperties().get("clip")); } } } }); Scene scene = new Scene(vbox, 200, 400); stage.setScene(scene); stage.show(); } HBox mkSP(NodeOrientation nodeOrientation) { HBox hbox = new HBox(4); hbox.setNodeOrientation(nodeOrientation); Group group = new Group(); Button button = new Button("Hello"); button.setLayoutX(5); button.setLayoutY(15); Line line = new Line(0, 0, 200, 200); Text text = new Text("Hello"); double x = 7, y = 100; text.setLayoutX(x); text.setLayoutY(y); double textWidth = text.getLayoutBounds().getWidth(); double textHeight = text.getLayoutBounds().getHeight(); Rectangle box = new Rectangle(textWidth, textHeight); box.setStroke(Color.BLACK); box.setStrokeWidth(1); box.setFill(Color.TRANSPARENT); box.setLayoutX(x); box.setLayoutY(y); group.getChildren().addAll(button, line, text, box); ScrollPane sp = new ScrollPane(); sp.setContent(group); sp.setPrefSize(100, 100); sp.setPannable(true); sp.setVisible(true); hbox.getChildren().add(new Label(((nodeOrientation == LEFT_TO_RIGHT) ? "LTR" : "RTL"))); hbox.getChildren().add(sp); return hbox; } public static void main(String[] args) { launch(args); } }