Duplicate :
|
|
Relates :
|
|
Relates :
|
Look at the attached movie. I used this app: import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.ScrollPane; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.scene.shape.Line; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class JavaApplication3 extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { Pane pane = new Pane(); pane.setPrefSize(400, 400); ScrollPane sp = new ScrollPane();sp.setFocusTraversable(false); sp.setPrefSize(150, 150); sp.setContent(createCustomContent(200, 200)); pane.getChildren().add(sp); Scene scene = new Scene(pane, 400, 400); stage.setScene(scene); stage.show(); } public static Group createCustomContent(int height, int width) { Group res = new Group(); Rectangle r = new Rectangle(); r.setStroke(Color.BLACK); r.setStyle("-fx-border-color: GREEN;"); res.getChildren().add(r); for (int i = 10; i < height; i += 10) { Line line1 = new Line(0, i, i - 5, i); Line line2 = new Line(i, 0, i, i - 5); Line line3 = new Line(i - 5, i, i - 5, height); Line line4 = new Line(i, i - 5, width, i - 5); line1.setStroke(Color.RED); line2.setStroke(Color.YELLOW); line3.setStroke(Color.BLUE); line4.setStroke(Color.MAGENTA); res.getChildren().addAll(line1, line2, line3, line4); } Rectangle rec = new Rectangle(0, 0, width, height); rec.setFill(Color.TRANSPARENT); rec.setStroke(Color.RED); res.getChildren().add(rec); return res; } }
|