Skip to content

Instantly share code, notes, and snippets.

@RuZman
Created March 28, 2015 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RuZman/0e20597a67daff8aba25 to your computer and use it in GitHub Desktop.
Save RuZman/0e20597a67daff8aba25 to your computer and use it in GitHub Desktop.
DataFX Demo
<?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>
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);
}
}
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();
}
}
<?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>
<?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>
package de.ruzman.datafxdemo;
import io.datafx.controller.FXMLController;
@FXMLController("fxml/Menu.Projekt.anlegen.fxml")
public class MenuProjektAnlegenController {
}
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());
}
}
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment