import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class StrokeFillEx extends Application {
public void start(Stage stage) {
initUI(stage);
}
private void initUI(Stage stage) {
Pane root = new Pane();
Canvas canvas = new Canvas(300, 300);
GraphicsContext gc = canvas.getGraphicsContext2D();
doDrawing(gc);
root.getChildren().add(canvas);
Scene scene = new Scene(root, 300, 250, Color.WHITESMOKE);
stage.setTitle("Stroke and fill");
stage.setScene(scene);
stage.show();
}
private void doDrawing(GraphicsContext gc) {
gc.setStroke(Color.RED.brighter());
gc.setLineWidth(5);
gc.strokeOval(30, 30, 80, 80);
gc.setFill(Color.RED);
gc.fillOval(130, 30, 80, 80);
}
public static void main(String[] args) {
launch(args);
}
}
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class StrokeFillEx extends Application {
public void start(Stage stage) {
initUI(stage);
}
private void initUI(Stage stage) {
Pane root = new Pane();
Canvas canvas = new Canvas(300, 300);
GraphicsContext gc = canvas.getGraphicsContext2D();
doDrawing(gc);
root.getChildren().add(canvas);
Scene scene = new Scene(root, 300, 250, Color.WHITESMOKE);
stage.setTitle("Stroke and fill");
stage.setScene(scene);
stage.show();
}
private void doDrawing(GraphicsContext gc) {
gc.setStroke(Color.RED.brighter());
gc.setLineWidth(5);
gc.strokeOval(30, 30, 80, 80);
gc.setFill(Color.RED);
gc.fillOval(130, 30, 80, 80);
}
public static void main(String[] args) {
launch(args);
}
}
No comments:
Post a Comment