import javafx.application.Application; import static javafx.application.Application.launch; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.control.ScrollPane; import javafx.scene.image.Image; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.stage.Stage; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author jvdrho0 */ public class Drawing extends Application { @Override public void start(Stage stage) throws Exception { AnchorPane root = new AnchorPane(); ScrollPane scroll = new ScrollPane(); scroll.setPrefHeight(100); scroll.setPrefWidth(100); HBox box = new HBox(); AnchorPane anchor=new AnchorPane(); Canvas canvas=new Canvas(75,75); GraphicsContext gc=canvas.getGraphicsContext2D(); Image im=new Image(Drawing.class.getResourceAsStream("dna.png")); gc.drawImage(im, 5, 5); gc.setStroke(Color.GREEN); gc.strokeText("1", 59, 15); gc.setStroke(Color.RED); gc.strokeText("2", 59, 28); gc.setStroke(Color.BLUE); gc.strokeText("1", 59, 41); anchor.getChildren().add(canvas); box.getChildren().add(anchor); anchor=new AnchorPane(); canvas=new Canvas(75,75); gc=canvas.getGraphicsContext2D(); im=new Image(Drawing.class.getResourceAsStream("dna.png")); gc.drawImage(im, 5, 5); gc.setStroke(Color.GREEN); gc.strokeText("1", 59, 15); gc.setStroke(Color.RED); gc.strokeText("2", 59, 28); gc.setStroke(Color.BLUE); gc.strokeText("1", 59, 41); anchor.getChildren().add(canvas); box.getChildren().add(anchor); anchor=new AnchorPane(); canvas=new Canvas(75,75); gc=canvas.getGraphicsContext2D(); im=new Image(Drawing.class.getResourceAsStream("dna.png")); gc.drawImage(im, 5, 5); gc.setStroke(Color.GREEN); gc.strokeText("1", 59, 15); gc.setStroke(Color.RED); gc.strokeText("2", 59, 28); gc.setStroke(Color.BLUE); gc.strokeText("1", 59, 41); anchor.getChildren().add(canvas); box.getChildren().add(anchor); scroll.setContent(box); root.getChildren().add(scroll); Scene scene = new Scene(root, 150, 150); stage.setTitle("Image Test"); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } }