Dateien Aus Workshop übernommen.
This commit is contained in:
parent
0d67cd457f
commit
221b1b8f03
|
@ -28,7 +28,7 @@ dependencies {
|
||||||
// Configuration for Application plugin
|
// Configuration for Application plugin
|
||||||
application {
|
application {
|
||||||
// Define the main class for the application.
|
// Define the main class for the application.
|
||||||
mainClass = 'ch.zhaw.prog2.application.WordModel'
|
mainClass = 'ch.zhaw.prog2.application.App'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configuration for JavaFX plugin
|
// Configuration for JavaFX plugin
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.*?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import java.lang.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
|
||||||
|
<AnchorPane prefHeight="480.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.prog2.application.MainWindowController">
|
||||||
|
<children>
|
||||||
|
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<children>
|
||||||
|
<Label fx:id="labelTitel" text="Label" />
|
||||||
|
<TextField fx:id="textEingabe" maxWidth="300.0" />
|
||||||
|
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="10.0">
|
||||||
|
<children>
|
||||||
|
<Button mnemonicParsing="false" onAction="#hinzufuegenText" text="Hinzufügen Text" />
|
||||||
|
<Button mnemonicParsing="false" onAction="#leerenTextEingabe" text="Löschen Eingabefeld" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
<TextArea fx:id="textHistory" editable="false" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" />
|
||||||
|
</children>
|
||||||
|
<padding>
|
||||||
|
<Insets top="10.0" />
|
||||||
|
</padding>
|
||||||
|
</VBox>
|
||||||
|
</children>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="20.0" />
|
||||||
|
</padding>
|
||||||
|
</AnchorPane>
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
|
|
||||||
<AnchorPane xmlns:fx="http://javafx.com/fxml/1">
|
|
||||||
<!-- TODO Add Nodes -->
|
|
||||||
</AnchorPane>
|
|
||||||
|
|
Loading…
Reference in New Issue