Skip to content

Commit

Permalink
Level 10: GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
gx-huang committed Feb 1, 2020
1 parent 7029797 commit 4a0115f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 18 deletions.
38 changes: 21 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.api.plugins.internal.DefaultJavaApplication

plugins {
id 'java'
id 'application'
Expand All @@ -10,33 +12,35 @@ repositories {
mavenCentral()
}

application {
final def application = application {
// Change this to your main class.
mainClassName = "Duke"
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.0'
mainClassName = "Duke.class"
}
application

test {
useJUnitPlatform()
}

/*plugins {
id 'java'
id 'org.openjfx.javafxplugin' version '0.0.7'
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.0'

repositories {
mavenCentral()
String javaFxVersion = '11'

implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
}

javafx {
version = "11.0.2"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}*/

run {
standardInput = System.in
}
15 changes: 14 additions & 1 deletion src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;

public class Duke {
public class Duke extends Application {

private DukeStorage storage;
private UserText tasks;
Expand All @@ -21,4 +25,13 @@ public void run() {
public static void main(String[] args) throws DukeException {
new Duke("data/tasks.txt").run();
}

@Override
public void start(Stage stage) {
Label helloWorld = new Label("Hello World!"); // Creating a new Label control
Scene scene = new Scene(helloWorld); // Setting the scene to be our Label

stage.setScene(scene); // Setting the stage to show our screen
stage.show(); // Render the stage.
}
}
11 changes: 11 additions & 0 deletions src/main/java/Launcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import javafx.application.Application;

/**
* A launcher class to workaround classpath issues.
*/
public class Launcher {
public static void main(String[] args) {
Application.launch(Duke.class, args);
}
}

0 comments on commit 4a0115f

Please sign in to comment.