Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. package main;
  2. import controller.ControllerClass;
  3. import javafx.application.Application;
  4. import javafx.fxml.FXMLLoader;
  5. import javafx.scene.Parent;
  6. import javafx.scene.Scene;
  7. import javafx.scene.layout.BorderPane;
  8. import javafx.stage.Stage;
  9. import model.InitGui;
  10. import view.*;
  11. public class Main extends Application {
  12. public static void main(String[] args) {
  13. launch(args);
  14. }
  15. @Override
  16. public void start(Stage primaryStage) throws Exception {
  17. try {
  18. FXMLLoader loader = new FXMLLoader(getClass().getResource("/view/Design.fxml"));
  19. Parent root = loader.load();
  20. Scene scene = new Scene(root);
  21. // optionally add a stylesheet
  22. primaryStage.setScene(scene);
  23. // obtain controller
  24. ControllerClass controller = loader.getController();
  25. // set model
  26. controller.setModel(new InitGui());
  27. primaryStage.show();
  28. } catch(Exception e) {
  29. e.printStackTrace();
  30. }
  31. }
  32. }
  33.  
  34. package controller;
  35. import java.io.IOException;
  36.  
  37. import javafx.application.Application;
  38. import javafx.fxml.FXML;
  39. import javafx.fxml.FXMLLoader;
  40. import javafx.scene.Parent;
  41. import javafx.scene.Scene;
  42. import javafx.scene.control.TextField;
  43. import model.InitGui;
  44.  
  45.  
  46. public class ControllerClass {
  47. @FXML
  48. public TextField fxWeeks;
  49. public InitGui initGui;
  50. public void setModel(InitGui initGui) {
  51. this.initGui = initGui;
  52. }
  53. public ControllerClass () {
  54. fxWeeks.setText(initGui.getExample());
  55. }
  56. }
  57.  
  58. package model;
  59. import javafx.fxml.FXML;
  60. import javafx.scene.control.TextField;
  61. public class InitGui {
  62. public String getExample () {
  63. return "Hello";
  64. }
  65. }
  66.  
  67. <?xml version="1.0" encoding="UTF-8"?>
  68. <?import javafx.scene.control.*?>
  69. <?import java.lang.*?>
  70. <?import javafx.scene.layout.*?>
  71. <Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="450" prefWidth="450" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.controller.ControllerClass">
  72. <MenuBar fx:id="menuBar">
  73. <menus>
  74. <Menu text="Datei">
  75. <MenuItem text="Öffnen"/>
  76. <MenuItem text="Speichern"/>
  77. <MenuItem text="Speichern unter"/>
  78. <SeparatorMenuItem />
  79. <MenuItem text="Schließen"/>
  80. </Menu>
  81. </menus>
  82. </MenuBar>
  83. <children>
  84. <TableView fx:id="fxTable" layoutX="10.0" layoutY="75.0" prefHeight="410.0" prefWidth="600.0"/>
  85. <Label fx:id="fxLabel" layoutX="630.0" layoutY="60.0" Text="Kalenderwoche"/>
  86. <TextField fx:id="fxWeek" layoutX="630.0" layoutY="75.0" prefWidth="95.0"/>
  87. <Button fx:id="fxButton" layoutX="630.0" layoutY="125.0" Text="Arbeitszeit berechnen"/>
  88. <Label fx:id="fxAlllbl" layoutX="10.0" layoutY="500.0" Text="Gesamt :"/>
  89. <TextField fx:id="fxAllContent" layoutX="80.0" layoutY="497.0"/>
  90. </children>
  91. </Pane>
  92.  
  93. public class Main extends Application {
  94. @Override
  95. public void start(Stage primaryStage) {
  96. try {
  97. FXMLLoader loader = new FXMLLoader(getClass().getResource("fxmlFileName.fxml"));
  98. BorderPane root = loader.load();
  99. Scene scene = new Scene(root);
  100. // optionally add a stylesheet
  101. scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
  102. primaryStage.setScene(scene);
  103. // obtain controller
  104. ControllerClass controller = loader.getController();
  105. // set model
  106. controller.setModel(new Model());
  107. primaryStage.show();
  108. } catch(Exception e) {
  109. e.printStackTrace();
  110. }
  111. }
  112.  
  113. public static void main(String[] args) {
  114. launch(args);
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement