Skip to content
Snippets Groups Projects
Commit ed4b8024 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

lab01

parents
Branches
No related merge requests found
/target/
.settings/
.project
.classpath
pom.xml 0 → 100644
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>vsb-cs-java1</groupId>
<artifactId>lab01</artifactId>
<version>0.0.1-SNAPHOST</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-params -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package lab;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
/**
* Class <b>App</b> - extends class Application and it is an entry point of the program
* @author Java I
*/
public class App extends Application {
public static void main(String[] args) {
launch(args);
}
private Canvas canvas;
@Override
public void start(Stage primaryStage) {
try {
//Construct a main window with a canvas.
Group root = new Group();
canvas = new Canvas(800, 400);
root.getChildren().add(canvas);
Scene scene = new Scene(root, 800, 400);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.resizableProperty().set(false);
primaryStage.setTitle("Java 1 - 1th laboratory");
primaryStage.show();
//Exit program when main window is closed
primaryStage.setOnCloseRequest(this::exitProgram);
//Draw scene on a separate thread to avoid blocking UI.
new Thread(this::drawScene).start();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Draws objects into the canvas. Put you code here.
*
*@return nothing
*/
private void drawScene() {
//graphic context is used for a painting
GraphicsContext gc = canvas.getGraphicsContext2D();
// put your code here
// gc.setFill(Color.AQUA);
// gc.setStroke(Color.BLACK);
}
private void exitProgram(WindowEvent evt) {
System.exit(0);
}
}
\ No newline at end of file
package lab;
public class Routines {
public static void sleep(int timeInMilisenonds) {
try {
Thread.sleep(timeInMilisenonds);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
public static boolean isEndOfThreadRequestedByJavaVM() {
return Thread.interrupted();
}
}
module lab01 {
requires transitive javafx.controls;
requires javafx.fxml;
opens lab to javafx.fxml;
exports lab;
}
\ No newline at end of file
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment