aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
diff options
context:
space:
mode:
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);