-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLauncher.java
More file actions
49 lines (45 loc) · 1.67 KB
/
Copy pathLauncher.java
File metadata and controls
49 lines (45 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package openconsignment;
import java.io.InputStream;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import openconsignment.common.Utils;
import openconsignment.di.AppComponent;
import openconsignment.di.DaggerAppComponent;
public class Launcher extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
try {
String mainFxmlPath = "/fxml/Main.fxml";
URL resource = getClass().getResource(mainFxmlPath);
if (resource == null) {
throw new RuntimeException("Resource not found");
}
AppComponent component = DaggerAppComponent.create();
FXMLLoader loader = new FXMLLoader(resource);
loader.setControllerFactory(component.controllerFactory());
Parent root = loader.load();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setMaximized(true);
stage.show();
InputStream resourceAsStream = getClass().getResourceAsStream("/icons/opaque_logo.png");
if (resourceAsStream != null) {
stage.getIcons().add(new Image(resourceAsStream));
}
stage.setTitle("OpenConsignment");
} catch (Exception ex) {
Utils.showAlert(ex.toString());
Logger.getLogger(Launcher.class.getName()).log(Level.SEVERE, ex.toString(), ex);
}
}
}