Aufgabe 1 ausgeführt.
This commit is contained in:
parent
221b1b8f03
commit
0488d50f79
|
@ -8,7 +8,7 @@ import javafx.stage.Stage;
|
||||||
|
|
||||||
public class MainWindow extends Application {
|
public class MainWindow extends Application {
|
||||||
|
|
||||||
|
WordModel wordModel = new WordModel();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
|
@ -23,7 +23,7 @@ public class MainWindow extends Application {
|
||||||
|
|
||||||
MainWindowController mainWindowController = loader.getController();
|
MainWindowController mainWindowController = loader.getController();
|
||||||
//mainWindowController.connectProperties(); //nicht benötigt, da in der Methode MainWindowController in initialize aufgerufen wird.
|
//mainWindowController.connectProperties(); //nicht benötigt, da in der Methode MainWindowController in initialize aufgerufen wird.
|
||||||
|
mainWindowController.setWordModel(wordModel);
|
||||||
|
|
||||||
Scene scene = new Scene(rootNode);
|
Scene scene = new Scene(rootNode);
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,12 @@ import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TextArea;
|
import javafx.scene.control.TextArea;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class MainWindowController {
|
public class MainWindowController {
|
||||||
|
|
||||||
|
|
||||||
|
WordModelDecorator wordModelDecorator;
|
||||||
|
|
||||||
public void initialize(){
|
public void initialize(){
|
||||||
connectProperties();
|
connectProperties();
|
||||||
|
@ -25,10 +28,10 @@ public class MainWindowController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void hinzufuegenText(ActionEvent event) {
|
void hinzufuegenText(ActionEvent event) {
|
||||||
String text = textHistory.getText();
|
String[] text = textEingabe.getText().toLowerCase().split(" ");
|
||||||
text += textEingabe.getText() + "\n";
|
for(String word : text) {
|
||||||
textHistory.setText(text);
|
wordModelDecorator.addWord(word);
|
||||||
textEingabe.clear();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -36,7 +39,15 @@ public class MainWindowController {
|
||||||
textEingabe.clear();
|
textEingabe.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setWordModel(WordModel wordModel){
|
||||||
|
wordModelDecorator = new WordModelDecorator(wordModel);
|
||||||
|
wordModelDecorator.addListener(new IsObserver() {
|
||||||
|
@Override
|
||||||
|
public void update() {
|
||||||
|
textHistory.setText(wordModel.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void connectProperties() {
|
void connectProperties() {
|
||||||
// erste Möglichkeit
|
// erste Möglichkeit
|
||||||
|
|
Loading…
Reference in New Issue