vtm-theme-comparator: fix application exit #387
This commit is contained in:
parent
81a270428c
commit
4532e397c0
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017 Longri
|
* Copyright 2017 Longri
|
||||||
|
* Copyright 2017 devemux86
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
* 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
|
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
@ -35,15 +36,15 @@ import javax.swing.JMenuItem;
|
|||||||
|
|
||||||
public class MainMenu extends JMenuBar {
|
public class MainMenu extends JMenuBar {
|
||||||
|
|
||||||
private final MapLoader mapLoader;
|
private final MainWindow mainWindow;
|
||||||
private final JMenu fileMenu = new JMenu("File");
|
private final JMenu fileMenu = new JMenu("File");
|
||||||
private final JMenu viewMenu = new JMenu("View");
|
private final JMenu viewMenu = new JMenu("View");
|
||||||
private final JMenu posMenu = new JMenu("Pos");
|
private final JMenu posMenu = new JMenu("Pos");
|
||||||
private ThemeLoader themeLoader;
|
private ThemeLoader themeLoader;
|
||||||
|
|
||||||
MainMenu(MapLoader mapLoader, BothMapPositionHandler mapPosition) {
|
MainMenu(MainWindow mainWindow) {
|
||||||
this.mapLoader = mapLoader;
|
this.mainWindow = mainWindow;
|
||||||
mapPosition.setCallBack(this);
|
mainWindow.bothMapPositionHandler.setCallBack(this);
|
||||||
addFileEntrys();
|
addFileEntrys();
|
||||||
addViewEntrys();
|
addViewEntrys();
|
||||||
addPosEntrys();
|
addPosEntrys();
|
||||||
@ -86,7 +87,7 @@ public class MainMenu extends JMenuBar {
|
|||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
System.exit(0);
|
mainWindow.exit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return item;
|
return item;
|
||||||
@ -114,7 +115,7 @@ public class MainMenu extends JMenuBar {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
mapLoader.loadMap(new File(mapPath), true);
|
mainWindow.mapLoader.loadMap(new File(mapPath), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -33,8 +33,8 @@ import javax.swing.WindowConstants;
|
|||||||
class MainWindow extends JFrame {
|
class MainWindow extends JFrame {
|
||||||
|
|
||||||
private final VtmPanel vtmPanel;
|
private final VtmPanel vtmPanel;
|
||||||
private final MapLoader mapLoader;
|
final MapLoader mapLoader;
|
||||||
private final BothMapPositionHandler bothMapPositionHandler;
|
final BothMapPositionHandler bothMapPositionHandler;
|
||||||
private final MapsforgeMapPanel mapsforgeMapPanel;
|
private final MapsforgeMapPanel mapsforgeMapPanel;
|
||||||
private final InfoPanel infoPanel;
|
private final InfoPanel infoPanel;
|
||||||
private final MapsPanel mapsPanel;
|
private final MapsPanel mapsPanel;
|
||||||
@ -66,7 +66,7 @@ class MainWindow extends JFrame {
|
|||||||
|
|
||||||
mapLoader = new MapLoader(mapsforgeMapPanel, vtmPanel, bothMapPositionHandler);
|
mapLoader = new MapLoader(mapsforgeMapPanel, vtmPanel, bothMapPositionHandler);
|
||||||
|
|
||||||
MainMenu mainMenu = new MainMenu(mapLoader, bothMapPositionHandler);
|
MainMenu mainMenu = new MainMenu(this);
|
||||||
setJMenuBar(mainMenu);
|
setJMenuBar(mainMenu);
|
||||||
|
|
||||||
infoPanel = new InfoPanel(vtmPanel, mapsforgeMapPanel, mainMenu);
|
infoPanel = new InfoPanel(vtmPanel, mapsforgeMapPanel, mainMenu);
|
||||||
@ -86,12 +86,15 @@ class MainWindow extends JFrame {
|
|||||||
addWindowListener(new WindowAdapter() {
|
addWindowListener(new WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
mapsforgeMapPanel.destroy();
|
exit();
|
||||||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
|
||||||
dispose();
|
|
||||||
System.exit(0);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void exit() {
|
||||||
|
mapsforgeMapPanel.destroy();
|
||||||
|
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
|
dispose();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017 Longri
|
* Copyright 2017 Longri
|
||||||
|
* Copyright 2017 devemux86
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
* 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
|
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
@ -34,6 +35,7 @@ public class VtmPanel extends JPanel {
|
|||||||
|
|
||||||
public VtmPanel(MapApplicationAdapter.MapReadyCallback callback) {
|
public VtmPanel(MapApplicationAdapter.MapReadyCallback callback) {
|
||||||
this.setLayout(null);
|
this.setLayout(null);
|
||||||
|
LwjglApplicationConfiguration.disableAudio = true;
|
||||||
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
|
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
|
||||||
config.width = 300;
|
config.width = 300;
|
||||||
config.height = 300;
|
config.height = 300;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user