├── src ├── main │ ├── resources │ │ ├── application.properties │ │ ├── fxml │ │ │ ├── Main.fxml │ │ │ └── tabs │ │ │ │ ├── TabPane.fxml │ │ │ │ ├── LoggerTab.fxml │ │ │ │ └── ConsoleTab.fxml │ │ └── specs │ │ │ ├── Skylab │ │ │ ├── Shuttle │ │ │ └── Apollo │ └── java │ │ └── com │ │ └── mvp │ │ └── java │ │ ├── controllers │ │ ├── LoggerTabController.java │ │ ├── TabPaneManger.java │ │ └── ConsoleTabController.java │ │ ├── spring │ │ └── config │ │ │ └── AppJavaConfig.java │ │ ├── services │ │ └── MissionsService.java │ │ └── Main.java └── test │ └── java │ └── com │ └── mvp │ └── java │ └── ConsoleTabTests.java ├── .gitignore ├── README.md └── pom.xml /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | specs.dir=/specs/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | -------------------------------------------------------------------------------- /src/main/java/com/mvp/java/controllers/LoggerTabController.java: -------------------------------------------------------------------------------- 1 | package com.mvp.java.controllers; 2 | 3 | import javafx.fxml.FXML; 4 | import javafx.scene.control.TextArea; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class LoggerTabController { 9 | 10 | @FXML private TextArea loggerTxtArea; 11 | 12 | public TextArea getLoggerTxtArea() { 13 | return loggerTxtArea; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/resources/fxml/Main.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/java/com/mvp/java/spring/config/AppJavaConfig.java: -------------------------------------------------------------------------------- 1 | package com.mvp.java.spring.config; 2 | 3 | import java.io.PrintWriter; 4 | import java.io.StringWriter; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.context.annotation.Scope; 8 | 9 | @Configuration 10 | public class AppJavaConfig { 11 | 12 | @Bean(name = "stringPrintWriter") @Scope("prototype") 13 | public PrintWriter printWriter(){ 14 | // useful when dumping stack trace to file 15 | return new PrintWriter(new StringWriter()); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # springboot-javafx-tutorial 2 | Show you how to Integrate Spring Boot with JavaFX - Tutorial 3 | 4 | Specifically shows you how to integrate Spring with JavaFX 8 via Spring Boot. 5 | Describes how to use Spring as the main Java FX Controller Factory and 6 | how to use @Autowired into your Java FX Controllers to get access 7 | to your other Spring Services (@Service) and beans (either via @Component or 8 | JavaConfig @Configuration). 9 | 10 | The example also showcases how you can take advantage of Spring Test for 11 | you Integration tests. 12 | 13 | You can follow along via MVP Java's YouTube Video Tutorial 14 | "Integrating Spring Boot with JavaFX" https://youtu.be/hjeSOxi3uPg 15 | -------------------------------------------------------------------------------- /src/main/java/com/mvp/java/controllers/TabPaneManger.java: -------------------------------------------------------------------------------- 1 | package com.mvp.java.controllers; 2 | 3 | import javafx.scene.control.TextArea; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class TabPaneManger { 9 | 10 | private final ConsoleTabController consoleTabController; 11 | private final LoggerTabController loggerTabController; 12 | 13 | @Autowired 14 | public TabPaneManger(ConsoleTabController consoleTabController, LoggerTabController loggerTabController) { 15 | this.consoleTabController = consoleTabController; 16 | this.loggerTabController = loggerTabController; 17 | } 18 | 19 | public TextArea getVisualLog() { 20 | return loggerTabController.getLoggerTxtArea(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/mvp/java/ConsoleTabTests.java: -------------------------------------------------------------------------------- 1 | package com.mvp.java; 2 | 3 | import com.mvp.java.services.MissionsService; 4 | import java.io.IOException; 5 | import static org.junit.Assert.*; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.SpringApplicationConfiguration; 10 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 11 | 12 | @RunWith(SpringJUnit4ClassRunner.class) 13 | @SpringApplicationConfiguration(classes = Main.class) 14 | public class ConsoleTabTests { 15 | 16 | @Autowired MissionsService missionsService; 17 | 18 | @Test 19 | public void retrieveMissionInfoSucessfully() throws IOException { 20 | String info = missionsService.getMissionInfo("Apollo"); 21 | assertTrue(!info.isEmpty()); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/resources/specs/Skylab: -------------------------------------------------------------------------------- 1 | Skylab 2 | ====== 3 | 4 | Skylab was a space station launched and operated by NASA and was the United 5 | States' first space station. Skylab orbited Earth from 1973 to 1979, and 6 | included a workshop, a solar observatory, and other systems. It was launched 7 | unmanned by a modified Saturn V rocket, with a weight of 170,000 pounds 8 | (77,111 kg).[1] Three manned expeditions to the station, conducted between 9 | May 1973 and February 1974 using the Apollo Command/Service Module (CSM) atop 10 | the smaller Saturn IB, each delivered a three-astronaut crew. On the last two 11 | manned missions, an additional Apollo / Saturn IB stood by ready to rescue the 12 | crew in orbit if it was needed. 13 | 14 | Specifications 15 | 16 | Crew Size: 3. Orbital Storage: 730 days. Habitable Volume: 361.00 m3. RCS 17 | Coarse No x Thrust: Reaction wheels. Electric System: 11.00 average kW. 18 | 19 | Gross mass: 76,295 kg (168,201 lb). 20 | Height: 36.12 m (118.50 ft). 21 | Span: 21.00 m (68.00 ft). 22 | First Launch: 1973.05.14. 23 | Number: 1 . 24 | -------------------------------------------------------------------------------- /src/main/java/com/mvp/java/services/MissionsService.java: -------------------------------------------------------------------------------- 1 | package com.mvp.java.services; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.InputStreamReader; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.stereotype.Service; 9 | 10 | @Service 11 | public class MissionsService { 12 | 13 | @Value(("${specs.dir}")) 14 | private String specsPath; 15 | 16 | public String getMissionInfo(String missionName) throws IOException { 17 | final StringBuilder fileContents = new StringBuilder(2000); 18 | final InputStream is = this.getClass().getResourceAsStream(specsPath + missionName); 19 | 20 | try (BufferedReader br = new BufferedReader(new InputStreamReader(is));) { 21 | String line; 22 | while ((line = br.readLine()) != null) { 23 | fileContents.append(line).append("\n"); 24 | } 25 | } 26 | return fileContents.toString(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/resources/fxml/tabs/TabPane.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/resources/specs/Shuttle: -------------------------------------------------------------------------------- 1 | the Shuttle 2 | =========== 3 | 4 | Since 1981, NASA space shuttles have been rocketing from the Florida coast into 5 | Earth orbit. The five orbiters — Columbia, Challenger, Discovery, Atlantis and 6 | Endeavour — have flown more than 130 times, carrying over 350 people into space 7 | and travelling more than half a billion miles, more than enough to reach Jupiter. 8 | 9 | 10 | SPECIFICATIONS 11 | 12 | First launch: 12-Apr-1981 13 | Number launches: 114 to end-2005 14 | Launch sites: KSC pads 39A/39B 15 | Principal uses: US manned capability to beyond 2010 (four reuseable Orbiter fleet), 25,000 kg payload delivery to LEO, satellite retrieval/in situ repair, short-duration science platform, Space Station assembly/servicing 16 | Vehicle success rate: 98.25% to end-2005 17 | Performance: 18 | LEO (204 km, 28.45o): 21,140 kg OV-102, 24,950 kg OV-103/104/105; each additional 19 | 1 km altitude reduces capacity by 25 kg, each crewmember beyond 5-person size 20 | reduces capacity by 230 kg into basic orbit 21 | LEO (204 km, 57o): 14,800 kg OV-102, 18,600 kg OV-103/104/105 (57o is usually the 22 | highest inclination flown from Florida, but dog-legging provides access to higher angles) 23 | LEO (204 km, 98o Sun-synchronous VAFB): 13,426 kg OV-103/104/105, assuming use if 24 | Advanced Solid Rocket Motors. Neither VAFB nor ASRM will be used 25 | Molniya (925 x 39,450 km, 63o): 3,563 kg using IUS via 222 km, 57o parking orbit 26 | Crossrange: 2,040 km max; 1,020-1,300 km used operationally by NASA -------------------------------------------------------------------------------- /src/main/resources/specs/Apollo: -------------------------------------------------------------------------------- 1 | Apollo (spacecraft) 2 | ================================================ 3 | The Apollo spacecraft was composed of three parts designed to accomplish the American Apollo 4 | program's goal of landing astronauts on the Moon by the end of the 1960s and returning them 5 | safely to Earth. The expendable (single-use) spacecraft consisted of a combined 6 | Command/Service Module (CSM) and a Lunar Module (LM). 7 | 8 | Two additional components 9 | complemented the spacecraft stack for space vehicle assembly: a Spacecraft 10 | Lunar Module Adapter (SLA) designed to shield the LM from the aerodynamic 11 | stress of launch, and to connect the CSM to the Saturn launch vehicle; 12 | and a Launch Escape System (LES) to carry the crew in the Command Module safely away from 13 | the launch vehicle in the event of a launch emergency. 14 | 15 | The design was based on the Lunar Orbit Rendezvous approach: two docked spacecraft were sent 16 | to the Moon and went into lunar orbit. While the LM separated and landed, the CSM remained 17 | in orbit. After the lunar excursion, the two craft rendezvoused and docked in lunar orbit, 18 | and the CSM returned the crew to Earth. The Command Module was the only part of the space 19 | vehicle that returned with the crew to the Earth's surface. 20 | 21 | 22 | Specifications 23 | 24 | Length minus BPC: 32 ft 6 in (9.92 m) 25 | Length with BPC: 39 ft 5 in (12.02 m) 26 | Diameter: 2 ft 2 in (0.66 m) 27 | Total mass: 9,200 pounds (4,200 kg) 28 | Thrust, 36,000 ft: 147,000 pounds-force (650 kN) 29 | Thrust, maximum: 200,000 pounds-force (890 kN) 30 | Burn time: 4.0 seconds -------------------------------------------------------------------------------- /src/main/resources/fxml/tabs/LoggerTab.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | --------------------------------------------------------------------------------