aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
diff options
context:
space:
mode:
authorDenis Lila <[email protected]>2011-06-10 13:13:02 -0400
committerDenis Lila <[email protected]>2011-06-10 13:13:02 -0400
commit96a0c7d49de812f2da4e085d1b26857774c105e4 (patch)
treeecdb1f133f90204f08271b8d11e15ad4b2e40c47 /netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
parent3346ae741ac0f052dfd419785108bc47903eaf5a (diff)
Fix undisposed window problem. It was causing AWT to never shut down.
Diffstat (limited to 'netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java')
-rw-r--r--netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java60
1 files changed, 35 insertions, 25 deletions
diff --git a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
index 0571044..5457306 100644
--- a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
+++ b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
@@ -57,6 +57,7 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
/** the display window */
private static JFrame frame;
+ private static final Object frameMutex = new Object();
/** shared constraint */
static GridBagConstraints vertical;
@@ -97,30 +98,32 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
public DownloadServiceListener getListener(ApplicationInstance app, String downloadName, URL resources[]) {
DownloadPanel result = new DownloadPanel(downloadName);
- if (frame == null) {
- frame = new JFrame(downloading + "...");
- frame.getContentPane().setLayout(new GridBagLayout());
- }
+ synchronized (frameMutex) {
+ if (frame == null) {
+ frame = new JFrame(downloading + "...");
+ frame.getContentPane().setLayout(new GridBagLayout());
+ }
- if (resources != null)
- for (int i = 0; i < resources.length; i++)
- result.addProgressPanel(resources[i], null);
+ if (resources != null)
+ for (int i = 0; i < resources.length; i++)
+ result.addProgressPanel(resources[i], null);
- frame.getContentPane().add(result, vertical);
- frame.pack();
+ frame.getContentPane().add(result, vertical);
+ frame.pack();
- if (!frame.isVisible()) {
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration());
- Dimension screen = new Dimension(screenSize.width - insets.left,
- screenSize.height - insets.top);
- frame.setLocation(screen.width - frame.getWidth(),
- screen.height - frame.getHeight());
- }
+ if (!frame.isVisible()) {
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration());
+ Dimension screen = new Dimension(screenSize.width - insets.left,
+ screenSize.height - insets.top);
+ frame.setLocation(screen.width - frame.getWidth(),
+ screen.height - frame.getHeight());
+ }
- frame.setVisible(true);
+ frame.setVisible(true);
- return result;
+ return result;
+ }
}
/**
@@ -134,11 +137,16 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
ActionListener hider = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
- if (frame.getContentPane().getComponentCount() == 1)
- frame.setVisible(false);
-
- frame.getContentPane().remove((DownloadPanel) listener);
- frame.pack();
+ synchronized(frameMutex) {
+ frame.getContentPane().remove((DownloadPanel) listener);
+ frame.pack();
+
+ if (frame.getContentPane().getComponentCount() == 0) {
+ frame.setVisible(false);
+ frame.dispose();
+ frame = null;
+ }
+ }
}
};
@@ -186,7 +194,9 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
ProgressPanel panel = new ProgressPanel(url, version);
add(panel, verticalIndent);
- frame.pack();
+ synchronized (frameMutex) {
+ frame.pack();
+ }
urls.add(url);
panels.add(panel);