From 221b1b8f03387ad717dd45e780f5b0246bccf5de Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Thu, 17 Mar 2022 20:59:16 +0100 Subject: [PATCH] =?UTF-8?q?Dateien=20Aus=20Workshop=20=C3=BCbernommen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/FXML-WordCloud/build.gradle | 2 +- .../java/ch/zhaw/prog2/application/App.java | 12 +++++ .../ch/zhaw/prog2/application/MainWindow.java | 37 +++++++++++++++ .../application/MainWindowController.java | 46 +++++++++++++++++++ .../ch/zhaw/prog2/application/MainWindow.fxml | 31 +++++++++++++ .../zhaw/prog2/fxmlcalculator/MainWindow.fxml | 8 ---- 6 files changed, 127 insertions(+), 9 deletions(-) create mode 100644 code/FXML-WordCloud/src/main/java/ch/zhaw/prog2/application/App.java create mode 100644 code/FXML-WordCloud/src/main/java/ch/zhaw/prog2/application/MainWindow.java create mode 100644 code/FXML-WordCloud/src/main/java/ch/zhaw/prog2/application/MainWindowController.java create mode 100644 code/FXML-WordCloud/src/main/resources/ch/zhaw/prog2/application/MainWindow.fxml delete mode 100644 code/FXML-WordCloud/src/main/resources/ch/zhaw/prog2/fxmlcalculator/MainWindow.fxml 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 @@ + + + + + + + + + + + + +