[Up]
Launch the application via Java Web Start.
Source Code
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.Group;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.stage.Stage;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
import javafx.scene.shape.ArcType;
public class FDrawTest extends Application {
public static void main(String args[]) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
Group root = new Group();
final Canvas canvas = new Canvas(400, 400);
draw(canvas.getGraphicsContext2D());
Scene scene = new Scene(root, 400, 400, Color.WHITE);
root.getChildren().add(canvas);
stage.setTitle("FDrawTest app");
stage.setScene(scene);
stage.show();
}
void draw(GraphicsContext gc) {
Font f1 = Font.font("DejaVu Serif", FontPosture.REGULAR, 24);
Font f2 = Font.font("DejaVu Sans", FontPosture.ITALIC, 24);
final String str = "Hello JavaFX World!";
gc.setFill(Color.BLACK);
gc.setFont(f1);
gc.fillText(str, 50, 30);
gc.setFont(f2);
gc.fillText(str, 80, 60);
gc.setStroke(Color.BLUE);
gc.strokeLine(10,10,100,100);
gc.setStroke(Color.GREEN);
gc.strokeRect(110,110,100,10);
gc.setFill(Color.YELLOW);
gc.fillRect(110,130,100,10);
gc.setFill(Color.ORANGE);
gc.fillRect(220,130,100,10);
gc.setStroke(Color.MAGENTA);
gc.strokeOval(110,150,100,50);
gc.setFill(Color.CYAN);
gc.fillOval(220,150,100,100);
gc.setFill(Color.PINK);
gc.fillArc(110,210,100,50,45,90,ArcType.ROUND);
gc.setStroke(Color.RED);
gc.strokeArc(110,230,100,50,135,270,ArcType.OPEN);
}
}
naniwa@rbt.his.u-fukui.ac.jp