Browse Source

Forgot to hand over the FXML loading to the new loader. Also, renamed the loader to be more descriptive of it's functionality.

master
Drew Short 11 years ago
parent
commit
32d9924a3a
  1. 7
      src/main/java/com/sothr/imagetools/App.java
  2. 8
      src/main/java/com/sothr/imagetools/util/ResourceLoader.java
  3. 4
      src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala

7
src/main/java/com/sothr/imagetools/App.java

@ -1,7 +1,7 @@
package com.sothr.imagetools;
import com.sothr.imagetools.errors.ImageToolsException;
import com.sothr.imagetools.util.FileLoader;
import com.sothr.imagetools.util.ResourceLoader;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
@ -13,8 +13,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Properties;
/**
@ -71,9 +69,8 @@ public class App extends Application
public void start(Stage primaryStage) throws Exception {
logger.info("Image-Tools is starting");
logger.info(String.format("Launching GUI with FXML file %s", MAINGUI_FXML));
ClassLoader cl = this.getClass().getClassLoader();
try {
Parent root = FXMLLoader.load(cl.getResource(MAINGUI_FXML));
Parent root = FXMLLoader.load(ResourceLoader.get().getResource(MAINGUI_FXML));
primaryStage.setScene(new Scene(root));
//config main scene
primaryStage.setTitle("Image Tools");

8
src/main/java/com/sothr/imagetools/util/FileLoader.java → src/main/java/com/sothr/imagetools/util/ResourceLoader.java

@ -6,13 +6,13 @@ import java.net.URL;
/**
* Created by drew on 1/5/14.
*/
public class FileLoader {
public class ResourceLoader {
private static final FileLoader instance = new FileLoader();
private static final ResourceLoader instance = new ResourceLoader();
private FileLoader() {}
private ResourceLoader() {}
public static FileLoader get() {
public static ResourceLoader get() {
return instance;
}

4
src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala

@ -10,7 +10,7 @@ import javafx.scene.Group
import javafx.scene.text.Text
import java.io.{IOException, File}
import java.util.Scanner
import com.sothr.imagetools.util.FileLoader
import com.sothr.imagetools.util.ResourceLoader
import java.net.URL
/**
@ -30,7 +30,7 @@ class AppController {
logger.debug("Displaying about screen")
var aboutMessage = "Simple About Message"
try {
aboutMessage = new Scanner(FileLoader.get().getResourceStream("documents/about")).useDelimiter("\\A").next()
aboutMessage = new Scanner(ResourceLoader.get().getResourceStream("documents/about")).useDelimiter("\\A").next()
} catch {
case ioe:IOException =>
logger.error("Unable to read about file")

Loading…
Cancel
Save