diff --git a/code/FXML-WordCloud/build.gradle b/code/FXML-WordCloud/build.gradle index 466e4a3..aa41707 100644 --- a/code/FXML-WordCloud/build.gradle +++ b/code/FXML-WordCloud/build.gradle @@ -28,7 +28,7 @@ dependencies { // Configuration for Application plugin application { // Define the main class for the application. - mainClass = 'ch.zhaw.prog2.application.WordModel' + mainClass = 'ch.zhaw.prog2.application.App' } // Configuration for JavaFX plugin diff --git a/code/FXML-WordCloud/src/main/java/ch/zhaw/prog2/application/App.java b/code/FXML-WordCloud/src/main/java/ch/zhaw/prog2/application/App.java new file mode 100644 index 0000000..b4da2c0 --- /dev/null +++ b/code/FXML-WordCloud/src/main/java/ch/zhaw/prog2/application/App.java @@ -0,0 +1,12 @@ +/* + * This Java source file was generated by the Gradle 'init' task. + */ +package ch.zhaw.prog2.application; + +import javafx.application.Application; + +public class App { + public static void main(String[] args) { + Application.launch(MainWindow.class, args); + } +} diff --git a/code/FXML-WordCloud/src/main/java/ch/zhaw/prog2/application/MainWindow.java b/code/FXML-WordCloud/src/main/java/ch/zhaw/prog2/application/MainWindow.java new file mode 100644 index 0000000..0a6f0af --- /dev/null +++ b/code/FXML-WordCloud/src/main/java/ch/zhaw/prog2/application/MainWindow.java @@ -0,0 +1,37 @@ +package ch.zhaw.prog2.application; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.layout.Pane; +import javafx.stage.Stage; + +public class MainWindow extends Application { + + + + @Override + public void start(Stage primaryStage) throws Exception { + openMainWindow(primaryStage); + } + + private void openMainWindow(Stage stage) { + try { + FXMLLoader loader = new FXMLLoader(getClass().getResource("MainWindow.fxml")); + + Pane rootNode = loader.load(); + + MainWindowController mainWindowController = loader.getController(); + //mainWindowController.connectProperties(); //nicht benötigt, da in der Methode MainWindowController in initialize aufgerufen wird. + + + Scene scene = new Scene(rootNode); + + stage.setScene(scene); + stage.show(); + } catch(Exception e) { + e.printStackTrace(); + } + + } +} diff --git a/code/FXML-WordCloud/src/main/java/ch/zhaw/prog2/application/MainWindowController.java b/code/FXML-WordCloud/src/main/java/ch/zhaw/prog2/application/MainWindowController.java new file mode 100644 index 0000000..3de2324 --- /dev/null +++ b/code/FXML-WordCloud/src/main/java/ch/zhaw/prog2/application/MainWindowController.java @@ -0,0 +1,46 @@ +package ch.zhaw.prog2.application; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Label; +import javafx.scene.control.TextArea; +import javafx.scene.control.TextField; + +public class MainWindowController { + + + + public void initialize(){ + connectProperties(); + } + + @FXML + private Label labelTitel; + + @FXML + private TextField textEingabe; + + @FXML + private TextArea textHistory; + + @FXML + void hinzufuegenText(ActionEvent event) { + String text = textHistory.getText(); + text += textEingabe.getText() + "\n"; + textHistory.setText(text); + textEingabe.clear(); + } + + @FXML + void leerenTextEingabe(ActionEvent event) { + textEingabe.clear(); + } + + + + void connectProperties() { + // erste Möglichkeit + labelTitel.textProperty().bind(textEingabe.textProperty()); + } + +} diff --git a/code/FXML-WordCloud/src/main/resources/ch/zhaw/prog2/application/MainWindow.fxml b/code/FXML-WordCloud/src/main/resources/ch/zhaw/prog2/application/MainWindow.fxml new file mode 100644 index 0000000..ca09c79 --- /dev/null +++ b/code/FXML-WordCloud/src/main/resources/ch/zhaw/prog2/application/MainWindow.fxml @@ -0,0 +1,31 @@ + + + + + + + + + + + + +