Fix headless operation, hopefully

This commit is contained in:
Christian committed 2012-09-02 13:29:46 -04:00
1 parent 10a716969b
commit 3d7a665987
2 files changed
+22 -31

No files matched your search

+21 -30
View File
@@ -18,7 +18,6 @@ import cpw.mods.fml.common.FMLLog;
public class Downloader extends JOptionPane public class Downloader extends JOptionPane
{ {
private static Downloader instance;
private JDialog container; private JDialog container;
private JLabel currentActivity; private JLabel currentActivity;
private JProgressBar progress; private JProgressBar progress;
@@ -28,21 +27,6 @@ public class Downloader extends JOptionPane
public Downloader() public Downloader()
{ {
super(); super();
instance = this;
setMessageType(JOptionPane.INFORMATION_MESSAGE);
setMessage(makeProgressPanel());
setOptions(new Object[] { "Stop" });
addPropertyChangeListener(new PropertyChangeListener()
{
@Override
public void propertyChange(PropertyChangeEvent evt)
{
if (evt.getSource() == instance && evt.getPropertyName()==VALUE_PROPERTY)
{
requestClose("This will stop minecraft from launching\nAre you sure you want to do this?");
}
}
});
} }
private Box makeProgressPanel() private Box makeProgressPanel()
@@ -66,19 +50,27 @@ public class Downloader extends JOptionPane
return box; return box;
} }
public static void main(String[] args)
{
instance = new Downloader();
instance.makeDialog();
}
JDialog makeDialog() JDialog makeDialog()
{ {
setMessageType(JOptionPane.INFORMATION_MESSAGE);
setMessage(makeProgressPanel());
setOptions(new Object[] { "Stop" });
addPropertyChangeListener(new PropertyChangeListener()
{
@Override
public void propertyChange(PropertyChangeEvent evt)
{
if (evt.getSource() == Downloader.this && evt.getPropertyName()==VALUE_PROPERTY)
{
requestClose("This will stop minecraft from launching\nAre you sure you want to do this?");
}
}
});
container = new JDialog(null, "Hello", ModalityType.MODELESS); container = new JDialog(null, "Hello", ModalityType.MODELESS);
container.setResizable(false); container.setResizable(false);
container.setLocationRelativeTo(null); container.setLocationRelativeTo(null);
container.add(instance); container.add(this);
instance.updateUI(); this.updateUI();
container.pack(); container.pack();
container.setMinimumSize(container.getPreferredSize()); container.setMinimumSize(container.getPreferredSize());
container.setVisible(true); container.setVisible(true);
@@ -88,7 +80,7 @@ public class Downloader extends JOptionPane
@Override @Override
public void windowClosing(WindowEvent e) public void windowClosing(WindowEvent e)
{ {
instance.requestClose("Closing this window will stop minecraft from launching\nAre you sure you wish to do this?"); requestClose("Closing this window will stop minecraft from launching\nAre you sure you wish to do this?");
} }
}); });
return container; return container;
@@ -132,11 +124,10 @@ public class Downloader extends JOptionPane
} }
} }
static void makeHeadless() void makeHeadless()
{ {
instance.container = null; container = null;
instance.progress = null; progress = null;
instance.currentActivity = null; currentActivity = null;
} }
} }
@@ -64,8 +64,8 @@ public class FMLRelauncher
} }
catch (Exception e) catch (Exception e)
{ {
Downloader.makeHeadless();
popupWindow = null; popupWindow = null;
RelaunchLibraryManager.downloadMonitor.makeHeadless();
} }
} }