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; package com.sothr.imagetools;
import com.sothr.imagetools.errors.ImageToolsException; import com.sothr.imagetools.errors.ImageToolsException;
import com.sothr.imagetools.util.FileLoader;
import com.sothr.imagetools.util.ResourceLoader;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
@ -13,8 +13,6 @@ import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Properties; import java.util.Properties;
/** /**
@ -71,9 +69,8 @@ public class App extends Application
public void start(Stage primaryStage) throws Exception { public void start(Stage primaryStage) throws Exception {
logger.info("Image-Tools is starting"); logger.info("Image-Tools is starting");
logger.info(String.format("Launching GUI with FXML file %s", MAINGUI_FXML)); logger.info(String.format("Launching GUI with FXML file %s", MAINGUI_FXML));
ClassLoader cl = this.getClass().getClassLoader();
try { try {
Parent root = FXMLLoader.load(cl.getResource(MAINGUI_FXML));
Parent root = FXMLLoader.load(ResourceLoader.get().getResource(MAINGUI_FXML));
primaryStage.setScene(new Scene(root)); primaryStage.setScene(new Scene(root));
//config main scene //config main scene
primaryStage.setTitle("Image Tools"); 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. * 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; 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 javafx.scene.text.Text
import java.io.{IOException, File} import java.io.{IOException, File}
import java.util.Scanner import java.util.Scanner
import com.sothr.imagetools.util.FileLoader
import com.sothr.imagetools.util.ResourceLoader
import java.net.URL import java.net.URL
/** /**
@ -30,7 +30,7 @@ class AppController {
logger.debug("Displaying about screen") logger.debug("Displaying about screen")
var aboutMessage = "Simple About Message" var aboutMessage = "Simple About Message"
try { try {
aboutMessage = new Scanner(FileLoader.get().getResourceStream("documents/about")).useDelimiter("\\A").next()
aboutMessage = new Scanner(ResourceLoader.get().getResourceStream("documents/about")).useDelimiter("\\A").next()
} catch { } catch {
case ioe:IOException => case ioe:IOException =>
logger.error("Unable to read about file") logger.error("Unable to read about file")

Loading…
Cancel
Save