Skip to content

Instantly share code, notes, and snippets.

@mkhelifi
Forked from RuZman/Main.java
Last active June 7, 2017 00:00

Revisions

  1. @RuZman RuZman created this gist Mar 28, 2015.
    17 changes: 17 additions & 0 deletions Main.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    package de.ruzman.datafxdemo;

    import io.datafx.controller.flow.Flow;
    import io.datafx.controller.flow.FlowException;
    import javafx.application.Application;
    import javafx.stage.Stage;

    public class Main extends Application {
    @Override
    public void start(Stage stage) throws FlowException {
    new Flow(MainController.class).startInStage(stage);
    }

    public static void main(String[] args) {
    launch(args);
    }
    }
    40 changes: 40 additions & 0 deletions MainController.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    package de.ruzman.datafxdemo;

    import io.datafx.controller.FXMLController;
    import io.datafx.controller.flow.Flow;
    import io.datafx.controller.flow.FlowException;
    import io.datafx.controller.flow.FlowHandler;
    import javafx.application.Platform;
    import javafx.event.ActionEvent;
    import javafx.fxml.FXML;
    import javafx.scene.layout.Pane;

    import javax.annotation.PostConstruct;

    @FXMLController("fxml/main.fxml")
    public class MainController {
    @FXML private Pane programmInhalt;

    private FlowHandler innerFlow;

    @PostConstruct
    public void init() throws FlowException {
    innerFlow = new Flow(MenuProjektAnlegenController.class).createHandler();
    programmInhalt.getChildren().add(innerFlow.start());
    }

    @FXML
    private void anlegenProjekt(ActionEvent actionEvent) throws Exception {
    innerFlow.navigateTo(MenuProjektAnlegenController.class);
    }

    @FXML
    private void anlegenService(ActionEvent actionEvent) throws Exception {
    innerFlow.navigateTo(MenuServiceAnlegenController.class);
    }

    @FXML
    private void beendeProgramm(ActionEvent actionEvent) {
    Platform.exit();
    }
    }
    22 changes: 22 additions & 0 deletions Menu.Projekt.anlegen.fxml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    <?xml version="1.0" encoding="UTF-8"?>

    <?import javafx.scene.text.*?>
    <?import javafx.geometry.*?>
    <?import java.lang.*?>
    <?import javafx.scene.layout.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.*?>

    <Pane fx:id="projektAnlegen" xmlns:fx="http://javafx.com/fxml">

    <Label layoutX="15.0" layoutY="70.0" text="Projektnummer" />

    <Label id="beispiellabel" layoutX="525.0" layoutY="70.0"
    text="Beispiel : 7432" />

    <TextField id="projektnummer" fx:id="projektnummer" layoutX="15.0"
    layoutY="90.0" prefHeight="25.0" prefWidth="670.0" />

    <Button id="erstelleProjekt" fx:id="erstelleProjekt" layoutX="15.0"
    layoutY="430.0" mnemonicParsing="false" text="Projektordner anlegen" />
    </Pane>
    25 changes: 25 additions & 0 deletions Menu.Service.anlegen.fxml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    <?xml version="1.0" encoding="UTF-8"?>

    <?import javafx.scene.text.*?>
    <?import javafx.geometry.*?>
    <?import java.lang.*?>
    <?import javafx.scene.layout.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.*?>

    <Pane fx:id="serviceAnlegen" xmlns:fx="http://javafx.com/fxml">

    <Label layoutX="15.0" layoutY="70.0" text="Servicenummer" />

    <Label id="beispiellabel" layoutX="525.0" layoutY="70.0"
    text="Beispiel : 1550" />

    <TextField id="servicejahr" fx:id="servicejahr" layoutX="15.0"
    layoutY="90.0" prefHeight="25.0" prefWidth="50.0" />
    <TextField id="servicenummer" fx:id="servicenummer" layoutX="65.0"
    layoutY="90.0" prefHeight="25.0" prefWidth="620.0" />

    <Button id="erstelleService" fx:id="erstelleService" layoutX="15.0"
    layoutY="430.0" onAction="#erstelleService" mnemonicParsing="false"
    text="Serviceordner anlegen" />
    </Pane>
    7 changes: 7 additions & 0 deletions MenuProjektAnlegenController.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    package de.ruzman.datafxdemo;

    import io.datafx.controller.FXMLController;

    @FXMLController("fxml/Menu.Projekt.anlegen.fxml")
    public class MenuProjektAnlegenController {
    }
    17 changes: 17 additions & 0 deletions MenuServiceAnlegenController.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    package de.ruzman.datafxdemo;

    import io.datafx.controller.FXMLController;
    import javafx.event.ActionEvent;
    import javafx.fxml.FXML;

    import javax.inject.Inject;

    @FXMLController("fxml/Menu.Service.anlegen.fxml")
    public class MenuServiceAnlegenController {
    @Inject private Model m;

    @FXML
    public void erstelleService(ActionEvent actionEvent) {
    System.out.println(m.getTestwert());
    }
    }
    17 changes: 17 additions & 0 deletions Model.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    package de.ruzman.datafxdemo;

    import io.datafx.controller.injection.scopes.ApplicationScoped;

    @ApplicationScoped
    public class Model {
    private int testwert = 22;
    private String version = "1.0.0";

    public int getTestwert() {
    return testwert;
    }

    public String getVersion() {
    return version;
    }
    }
    24 changes: 24 additions & 0 deletions main.fxml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    <?xml version="1.0" encoding="UTF-8"?>

    <?import javafx.scene.text.*?>
    <?import javafx.geometry.*?>
    <?import java.lang.*?>
    <?import javafx.scene.layout.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.*?>

    <VBox prefHeight="500.0" prefWidth="700.0" xmlns:fx="http://javafx.com/fxml">
    <MenuBar>
    <Menu text="Menü">
    <Menu text="Projekt">
    <MenuItem onAction="#anlegenProjekt" text="Projekt anlegen" />
    </Menu>
    <Menu text="Service">
    <MenuItem onAction="#anlegenService" text="Service anlegen" />
    </Menu>
    <SeparatorMenuItem />
    <MenuItem onAction="#beendeProgramm" text="Beenden" />
    </Menu>
    </MenuBar>
    <Pane fx:id="programmInhalt" />
    </VBox>