PacMan0.java [Last ned]

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.application.*;
import javafx.stage.*;
import javafx.scene.*;
 
public class PacMan0 extends Application {
 
  public static void main(String[] args) {
    launch(args);
  }
 
  public void start(Stage stage) {
    // Definerer vinduet og initierer scenegrafen
    Group root = new Group();
    Scene scene = new Scene(root, 800, 300);
    stage.setScene(scene);
    stage.setTitle("PacMan Enkel Demo");
 
    // Definerer "PacMan" med åpen munn (30-300 gr)
    Arc pacman = new Arc(100, 200, 50, 50, 30, 300);
    pacman.setStroke(Color.BLACK);
    pacman.setFill(Color.YELLOW);
    pacman.setType(ArcType.ROUND);
    root.getChildren().add(pacman);
 
    // Overskrift
    Font font = new Font("Arial", 44);
    Text txt = new Text(300, 80, "PacMan");
    txt.setStroke(Color.YELLOW);
    txt.setFill(Color.RED);
    txt.setFont(font);
    root.getChildren().add(txt);
 
    // Vis scenegrafen
    stage.show();
  }
 
}
 
Kildekode blir vist ved hjelp av GeSHi.