Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.application.Application;
- import javafx.stage.Stage;
- import javafx.scene.Scene;
- import javafx.scene.layout.StackPane;
- import javafx.scene.canvas.Canvas;
- import javafx.scene.canvas.GraphicsContext;
- import javafx.scene.paint.Color;
- public class FrameCanvas extends Application{
- public static void main(String[] args){
- launch(args);
- }
- @Override
- public void start(Stage primaryStage)throws Exception{
- ////////////////////Basic FX stuff
- Canvas theCanvas = new Canvas(900,900);
- StackPane theLayout = new StackPane();
- theLayout.getChildren().add(theCanvas);
- Scene theScene = new Scene(theLayout,900,900);
- primaryStage.setScene(theScene);
- primaryStage.show();
- ///////////////////////
- /////Drawing an X
- ///////////////////////
- GraphicsContext gc = theCanvas.getGraphicsContext2D();
- Thread.sleep(1000);
- gc.strokeLine(0,0,200,200);
- Thread.sleep(1000);
- gc.strokeLine(200,0,0,200);
- /////////////////////////////
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement