import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.shape.ArcType; import javafx.stage.Stage; import static javafx.application.Application.launch; import javafx.scene.paint.Color; /** * This is a slightly tweaked version of the happy face code from section 1.4 of * the textbook. * * @author Sam Scott * @author Walter Savitch */ public class HappyFace extends Application { /** * Start method (use this instead of main). * * @param stage The FX stage to draw on * @throws Exception */ @Override public void start(Stage stage) throws Exception { Group root = new Group(); Scene scene = new Scene(root); Canvas canvas = new Canvas(400, 300); root.getChildren().add(canvas); stage.setScene(scene); stage.show(); GraphicsContext gc = canvas.getGraphicsContext2D(); // YOUR STUFF GOES HERE (remove the code below) stage.setTitle("Section 1.4 Example"); gc.strokeOval(100, 50, 200, 200); gc.fillOval(155, 100, 10, 20); gc.fillOval(230, 100, 10, 20); gc.strokeArc(150, 160, 100, 50, 180, 180, ArcType.OPEN); } /** * The actual main method that launches the app * * @param args unused */ public static void main(String[] args) { launch(args); } }