Fix stopping threads again
This commit is contained in:
@ -34,8 +34,9 @@ import java.awt.FlowLayout;
|
||||
|
||||
public class Main {
|
||||
|
||||
private JFrame frame;
|
||||
private RegisteredFrame frame;
|
||||
private JTabbedPane tabbedPane;
|
||||
private OverviewTab overviewTab;
|
||||
private final WindowHandler windowHandler;
|
||||
private final ConfigurationManager _conf;
|
||||
public final static int FRAME_WIDTH = 550;
|
||||
@ -70,6 +71,24 @@ public class Main {
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop all the threads in overview tab
|
||||
* on plugin stop, but not on frame x-out
|
||||
* @since 0.0.4
|
||||
*/
|
||||
private class KillableFrame extends RegisteredFrame {
|
||||
public KillableFrame(String s, WindowHandler wh) {
|
||||
super(s, wh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kill() {
|
||||
if (overviewTab != null)
|
||||
overviewTab.destroy();
|
||||
super.kill();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the contents of the frame.
|
||||
*/
|
||||
@ -77,7 +96,7 @@ public class Main {
|
||||
GUIHelper.setDefaultStyle();
|
||||
//GUIHelper.setTabLooks();
|
||||
|
||||
frame = new RegisteredFrame("itoopie", windowHandler);
|
||||
frame = new KillableFrame("itoopie", windowHandler);
|
||||
frame.setBounds(0, 0, FRAME_WIDTH, FRAME_HEIGHT);
|
||||
frame.setResizable(false);
|
||||
frame.setBackground(GUIHelper.VERY_LIGHT);
|
||||
@ -91,7 +110,7 @@ public class Main {
|
||||
root.add(tabbedPane);
|
||||
tabbedPane.setBounds(0, 0, FRAME_WIDTH-9, TABBED_PANE_HEIGHT);
|
||||
|
||||
OverviewTab overviewTab = new OverviewTab("itoopie-opaque12", _conf);
|
||||
overviewTab = new OverviewTab("itoopie-opaque12", _conf);
|
||||
tabbedPane.addTab(' ' + Transl._t("Overview") + ' ', null, overviewTab, null);
|
||||
tabbedPane.addChangeListener(new TabChangeListener(overviewTab));
|
||||
|
||||
|
@ -6,10 +6,11 @@ import java.util.HashSet;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import net.i2p.itoopie.configuration.ConfigurationManager;
|
||||
import net.i2p.itoopie.gui.component.RegisteredFrame;
|
||||
|
||||
public class WindowHandler {
|
||||
private final HashSet<JFrame> _frames = new HashSet<JFrame>();
|
||||
private JFrame mainFrame;
|
||||
private RegisteredFrame mainFrame;
|
||||
private boolean areFramesShown;
|
||||
private final ConfigurationManager _conf;
|
||||
|
||||
@ -21,13 +22,13 @@ public class WindowHandler {
|
||||
_frames.add(frame);
|
||||
}
|
||||
|
||||
public void registerMain(JFrame frame){
|
||||
public void registerMain(RegisteredFrame frame){
|
||||
mainFrame = frame;
|
||||
}
|
||||
|
||||
public void destroyMain() {
|
||||
if (mainFrame != null) {
|
||||
mainFrame.dispose();
|
||||
mainFrame.kill();
|
||||
_frames.remove(mainFrame);
|
||||
mainFrame = null;
|
||||
}
|
||||
|
@ -61,4 +61,12 @@ public class RegisteredFrame extends JFrame implements WindowListener{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.0.4
|
||||
*/
|
||||
public void kill() {
|
||||
dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user