Aufgabe 4 MainWindow.fxml erstellt.
This commit is contained in:
parent
70dcb3fc71
commit
f0995fbf27
|
@ -34,7 +34,7 @@ application {
|
||||||
// Configuration for JavaFX plugin
|
// Configuration for JavaFX plugin
|
||||||
javafx {
|
javafx {
|
||||||
version = '17'
|
version = '17'
|
||||||
modules = [ 'javafx.controls' ]
|
modules = [ 'javafx.controls', 'javafx.fxml' ]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Java plugin configuration
|
// Java plugin configuration
|
||||||
|
|
|
@ -7,7 +7,7 @@ import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
/**
|
/**
|
||||||
* Main-Application. Opens the first window (MainWindow) and the common ValueHandler
|
* Main-Application. Opens the first window (MainWindow) and the common ValueHandler
|
||||||
* @author
|
* @author
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class Main extends Application {
|
public class Main extends Application {
|
||||||
|
@ -26,7 +26,28 @@ public class Main extends Application {
|
||||||
|
|
||||||
private void mainWindow(Stage primaryStage) {
|
private void mainWindow(Stage primaryStage) {
|
||||||
//load main window
|
//load main window
|
||||||
|
try {
|
||||||
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("MainWindow.fxml"));
|
||||||
|
|
||||||
|
Pane rootNode = loader.load();
|
||||||
|
|
||||||
|
MainWindowController mainWindowController = loader.getController();
|
||||||
|
|
||||||
|
|
||||||
|
Scene scene = new Scene(rootNode);
|
||||||
|
|
||||||
|
primaryStage.setScene(scene);
|
||||||
|
primaryStage.show();
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ import javafx.scene.control.TextField;
|
||||||
import javafx.scene.layout.*;
|
import javafx.scene.layout.*;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for the MainWindow. One controller per mask (or FXML file)
|
* Controller for the MainWindow. One controller per mask (or FXML file)
|
||||||
|
@ -17,6 +19,41 @@ import javafx.stage.Stage;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class MainWindowController {
|
public class MainWindowController {
|
||||||
// please complete
|
@FXML
|
||||||
|
private TextField annualCost;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CheckMenuItem clearAnnualCosts;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CheckMenuItem clearInitialAmount;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CheckMenuItem clearNumberOfYears;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CheckMenuItem clearReturnInPercent;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TextField initialAmount;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TextField numberOfYears;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TextArea results;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TextField returnInPercent;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void calculate(ActionEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void close(ActionEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,106 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
<AnchorPane xmlns:fx="http://javafx.com/fxml/1">
|
<?import javafx.scene.control.CheckMenuItem?>
|
||||||
<!-- TODO Add Nodes -->
|
<?import javafx.scene.control.Label?>
|
||||||
</AnchorPane>
|
<?import javafx.scene.control.Menu?>
|
||||||
|
<?import javafx.scene.control.MenuBar?>
|
||||||
|
<?import javafx.scene.control.MenuItem?>
|
||||||
|
<?import javafx.scene.control.SeparatorMenuItem?>
|
||||||
|
<?import javafx.scene.control.TextArea?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<?import javafx.scene.layout.HBox?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
|
<BorderPane prefHeight="400.0" prefWidth="300.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.prog2.fxmlcalculator.MainWindowController">
|
||||||
|
<top>
|
||||||
|
<MenuBar BorderPane.alignment="CENTER">
|
||||||
|
<menus>
|
||||||
|
<Menu mnemonicParsing="false" text="Clear">
|
||||||
|
<items>
|
||||||
|
<CheckMenuItem fx:id="clearInitialAmount" mnemonicParsing="false" text="Initial amount" />
|
||||||
|
<CheckMenuItem fx:id="clearReturnInPercent" mnemonicParsing="false" text="Return in%" />
|
||||||
|
<CheckMenuItem fx:id="clearAnnualCosts" mnemonicParsing="false" text="Annual Cost" />
|
||||||
|
<CheckMenuItem fx:id="clearNumberOfYears" mnemonicParsing="false" text="Number of years" />
|
||||||
|
<SeparatorMenuItem mnemonicParsing="false" />
|
||||||
|
<MenuItem mnemonicParsing="false" text="Clear values" />
|
||||||
|
<SeparatorMenuItem mnemonicParsing="false" />
|
||||||
|
<MenuItem mnemonicParsing="false" text="Clear results" />
|
||||||
|
</items>
|
||||||
|
</Menu>
|
||||||
|
<Menu mnemonicParsing="false" text="?">
|
||||||
|
<items>
|
||||||
|
<MenuItem mnemonicParsing="false" text="Show help F1" />
|
||||||
|
</items>
|
||||||
|
</Menu>
|
||||||
|
</menus>
|
||||||
|
</MenuBar>
|
||||||
|
</top>
|
||||||
|
<center>
|
||||||
|
<VBox prefHeight="0.0" prefWidth="0.0" BorderPane.alignment="CENTER">
|
||||||
|
<children>
|
||||||
|
<GridPane hgap="5.0" vgap="5.0">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Label text="Initial amount" />
|
||||||
|
<Label text="Return in %" GridPane.rowIndex="1" />
|
||||||
|
<Label text="Annual cost" GridPane.rowIndex="2" />
|
||||||
|
<Label text="Number of years" GridPane.rowIndex="3" />
|
||||||
|
<TextField fx:id="initialAmount" GridPane.columnIndex="1" />
|
||||||
|
<TextField fx:id="returnInPercent" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||||
|
<TextField fx:id="annualCost" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||||
|
<TextField fx:id="numberOfYears" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||||
|
</children>
|
||||||
|
<opaqueInsets>
|
||||||
|
<Insets />
|
||||||
|
</opaqueInsets>
|
||||||
|
</GridPane>
|
||||||
|
<Label text="Results:">
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets top="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Label>
|
||||||
|
<TextArea fx:id="results" prefHeight="200.0" prefWidth="380.0" />
|
||||||
|
</children>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
|
||||||
|
</padding>
|
||||||
|
</VBox>
|
||||||
|
</center>
|
||||||
|
<bottom>
|
||||||
|
<HBox alignment="BASELINE_CENTER" prefHeight="0.0" prefWidth="0.0" BorderPane.alignment="CENTER">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
|
||||||
|
</padding>
|
||||||
|
<children>
|
||||||
|
<Button lineSpacing="10.0" mnemonicParsing="false" onAction="#calculate" text="Calculate">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</Button>
|
||||||
|
<Button mnemonicParsing="false" onAction="#close" text="Close">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</Button>
|
||||||
|
</children>
|
||||||
|
<BorderPane.margin>
|
||||||
|
<Insets />
|
||||||
|
</BorderPane.margin>
|
||||||
|
</HBox>
|
||||||
|
</bottom>
|
||||||
|
</BorderPane>
|
||||||
|
|
Loading…
Reference in New Issue