diff --git a/gui/src/main/java/pl/marcinchwedczuk/elfviewer/gui/mainwindow/MainWindow.java b/gui/src/main/java/pl/marcinchwedczuk/elfviewer/gui/mainwindow/MainWindow.java index c9cd1b2..da42745 100644 --- a/gui/src/main/java/pl/marcinchwedczuk/elfviewer/gui/mainwindow/MainWindow.java +++ b/gui/src/main/java/pl/marcinchwedczuk/elfviewer/gui/mainwindow/MainWindow.java @@ -41,7 +41,7 @@ public static MainWindow showOn(Stage window) { Scene scene = new Scene(loader.load()); MainWindow controller = (MainWindow) loader.getController(); - window.setTitle("Main Window"); + window.setTitle("Elf Viewer"); window.setScene(scene); window.setResizable(true); @@ -61,7 +61,7 @@ public static MainWindow showOn(Stage window) { } } - private Window thisWindow; + private Stage thisWindow; @FXML private TextField filterText; @@ -156,6 +156,7 @@ private void loadElfFile(File f) { currentElfFile = null; currentElfPath = null; + setTitle(null); resetTreeView(); } @@ -163,6 +164,7 @@ private void loadElfFile(File f) { try { currentElfFile = ElfReader.readElf(new FileSystemFile(f)); currentElfPath = f; + setTitle(currentElfPath); } catch (ElfReaderException e) { UiService.errorDialog("Cannot open ELF file.", e.getMessage()); return; @@ -172,6 +174,14 @@ private void loadElfFile(File f) { recentlyOpenFiles.onFileOpen(f); } + private void setTitle(File elfFile) { + if (elfFile == null) { + thisWindow.setTitle("Elf Viewer"); + } else { + thisWindow.setTitle("Elf Viewer - " + elfFile.getName()); + } + } + private void resetTreeView() { rootItem = new TreeItem<>(new RenderDataAction<>( "No ELF file loaded",