Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import javafx.application.Application;
  2. import javafx.stage.Stage;
  3. import javafx.scene.Scene;
  4. import javafx.scene.layout.StackPane;
  5.  
  6. import javafx.scene.canvas.Canvas;
  7. import javafx.scene.canvas.GraphicsContext;
  8. import javafx.scene.paint.Color;
  9.  
  10. public class FrameCanvas extends Application{
  11. public static void main(String[] args){
  12. launch(args);
  13. }
  14. @Override
  15. public void start(Stage primaryStage)throws Exception{
  16. ////////////////////Basic FX stuff
  17. Canvas theCanvas = new Canvas(900,900);
  18. StackPane theLayout = new StackPane();
  19. theLayout.getChildren().add(theCanvas);
  20. Scene theScene = new Scene(theLayout,900,900);
  21. primaryStage.setScene(theScene);
  22. primaryStage.show();
  23. ///////////////////////
  24. /////Drawing an X
  25. ///////////////////////
  26. GraphicsContext gc = theCanvas.getGraphicsContext2D();
  27. Thread.sleep(1000);
  28. gc.strokeLine(0,0,200,200);
  29. Thread.sleep(1000);
  30. gc.strokeLine(200,0,0,200);
  31. /////////////////////////////
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement