JavaFX Tutorial - JavaFX Path
JavaFX Tutorial - JavaFX Path
Arc
Circle
CubicCurve
Ellipse
Line
Path
Polygon
Polyline
QuadCurve
Rectangle
SVGPath
Text
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.stage.Stage;
//from w w w . j a v a 2 s. c o m
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
Scene scene = new Scene(new Group());
stage.setTitle("Checkbox Sample");
stage.setWidth(230);
stage.setHeight(120);
((Group) scene.getRoot()).getChildren().add(root);
stage.setScene(scene);
stage.show();
}
}
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.scene.shape.QuadCurveTo;
import javafx.stage.Stage;
//from w w w .j a va2s .co m
public class Main extends Application {
@Override
public void start(Stage stage) {
Group root = new Group();
Scene scene = new Scene(root, 300, 150);
stage.setScene(scene);
stage.setTitle("");
path.getElements().add(moveTo);
path.getElements().add(quadTo);
root.getChildren().add(path);
scene.setRoot(root);
stage.show();
}
Example 2
Using Path, MoveTo and CubicCurveTo to create curve
@Override
public void start(Stage stage) {
stage.setTitle("ComboBoxSample");
Scene scene = new Scene(new Group(), 450, 250);
Example 3
Subtract two shapes to create a Path
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.DropShadow;
import javafx.scene.effect.DropShadowBuilder;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
Application.launch(args);//from w w w . ja v a 2 s. co m
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Shapes");
Group root = new Group();
Scene scene = new Scene(root, 300, 300, Color.WHITE);
.build();
root.getChildren().add(shape);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Example 4
Using VLineTo to create vertical line
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.scene.shape.VLineTo;
import javafx.stage.Stage;
/* ww w. j a va2s. co m*/
public class Main extends Application {
@Override
public void start(final Stage stage) {
stage.setTitle("HTML");
stage.setWidth(500);
stage.setHeight(500);
Scene scene = new Scene(new Group());
root.getChildren().addAll(path);
scene.setRoot(root);
stage.setScene(scene);
stage.show();
}