Skip to content

Commit

Permalink
vtm-theme-comparator: fix application exit #387
Browse files Browse the repository at this point in the history
  • Loading branch information
devemux86 committed Sep 5, 2017
1 parent 81a2704 commit 4532e39
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2017 Longri
* Copyright 2017 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
Expand Down Expand Up @@ -35,15 +36,15 @@

public class MainMenu extends JMenuBar {

private final MapLoader mapLoader;
private final MainWindow mainWindow;
private final JMenu fileMenu = new JMenu("File");
private final JMenu viewMenu = new JMenu("View");
private final JMenu posMenu = new JMenu("Pos");
private ThemeLoader themeLoader;

MainMenu(MapLoader mapLoader, BothMapPositionHandler mapPosition) {
this.mapLoader = mapLoader;
mapPosition.setCallBack(this);
MainMenu(MainWindow mainWindow) {
this.mainWindow = mainWindow;
mainWindow.bothMapPositionHandler.setCallBack(this);
addFileEntrys();
addViewEntrys();
addPosEntrys();
Expand Down Expand Up @@ -86,7 +87,7 @@ private JMenuItem itemExit() {
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
mainWindow.exit();
}
});
return item;
Expand Down Expand Up @@ -114,7 +115,7 @@ public void actionPerformed(ActionEvent e) {
ex.printStackTrace();
}

mapLoader.loadMap(new File(mapPath), true);
mainWindow.mapLoader.loadMap(new File(mapPath), true);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
class MainWindow extends JFrame {

private final VtmPanel vtmPanel;
private final MapLoader mapLoader;
private final BothMapPositionHandler bothMapPositionHandler;
final MapLoader mapLoader;
final BothMapPositionHandler bothMapPositionHandler;
private final MapsforgeMapPanel mapsforgeMapPanel;
private final InfoPanel infoPanel;
private final MapsPanel mapsPanel;
Expand Down Expand Up @@ -66,7 +66,7 @@ public void run() {

mapLoader = new MapLoader(mapsforgeMapPanel, vtmPanel, bothMapPositionHandler);

MainMenu mainMenu = new MainMenu(mapLoader, bothMapPositionHandler);
MainMenu mainMenu = new MainMenu(this);
setJMenuBar(mainMenu);

infoPanel = new InfoPanel(vtmPanel, mapsforgeMapPanel, mainMenu);
Expand All @@ -86,12 +86,15 @@ public void run() {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
mapsforgeMapPanel.destroy();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
dispose();
System.exit(0);
exit();
}
});
}

void exit() {
mapsforgeMapPanel.destroy();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
dispose();
System.exit(0);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2017 Longri
* Copyright 2017 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
Expand Down Expand Up @@ -34,6 +35,7 @@ public class VtmPanel extends JPanel {

public VtmPanel(MapApplicationAdapter.MapReadyCallback callback) {
this.setLayout(null);
LwjglApplicationConfiguration.disableAudio = true;
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = 300;
config.height = 300;
Expand Down

0 comments on commit 4532e39

Please sign in to comment.