changeset 988:8012d1bbbe72

Change download progress indicator to a JDialog The current download progress indicator window is a JFrame. Some window managers in Linux assume it's an application window and try to handle its size and position in a more appropriate way. A tiling window manager, for example, will resize it to fill the screen. Change it to a JDialog so it's treated as a dialog and its size and position are respected. 2014-05-02 Omair Majid <omajid@redhat.com> * netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java: Switch to JDialog from JFrame. Rename frame to dialog and frameMutex to dialogMutex. Adjust all Callers.
author Omair Majid <omajid@redhat.com>
date Fri, 02 May 2014 19:11:11 -0400
parents 57cc65b595c2
children e8b21e10ead6
files ChangeLog netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
diffstat 2 files changed, 34 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri May 02 17:48:24 2014 -0400
+++ b/ChangeLog	Fri May 02 19:11:11 2014 -0400
@@ -1,3 +1,9 @@
+2014-05-02  Omair Majid  <omajid@redhat.com>
+
+	* netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java: Switch to
+	JDialog from JFrame. Rename frame to dialog and frameMutex to dialogMutex.
+	Adjust all Callers.
+
 2014-05-02  Omair Majid  <omajid@redhat.com>
 
 	* netx/net/sourceforge/jnlp/cache/package-info.java,
--- a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java	Fri May 02 17:48:24 2014 -0400
+++ b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java	Fri May 02 19:11:11 2014 -0400
@@ -58,8 +58,8 @@
     private static final int CLOSE_DELAY = 750;
 
     /** the display window */
-    private static JFrame frame;
-    private static final Object frameMutex = new Object();
+    private static JDialog dialog;
+    private static final Object dialogMutex = new Object();
 
     /** shared constraint */
     static GridBagConstraints vertical;
@@ -104,9 +104,9 @@
     public DownloadServiceListener getListener(ApplicationInstance app, String downloadName, URL resources[]) {
         DownloadPanel result = new DownloadPanel(downloadName);
 
-        synchronized (frameMutex) {
-            if (frame == null) {
-                frame=createDownloadIndicatorFrame(true);
+        synchronized (dialogMutex) {
+            if (dialog == null) {
+                dialog = createDownloadIndicatorWindow(true);
             }
 
             if (resources != null) {
@@ -116,8 +116,8 @@
                 }
             }
 
-            frame.getContentPane().add(result, vertical);
-            frame.pack();
+            dialog.getContentPane().add(result, vertical);
+            dialog.pack();
             placeFrameToLowerRight();
             result.addComponentListener(new ComponentAdapter() {
                 @Override
@@ -126,14 +126,14 @@
                 }
             });
 
-            frame.setVisible(true);
+            dialog.setVisible(true);
 
             return result;
         }
     }
 
-     public static JFrame createDownloadIndicatorFrame(boolean undecorated) throws HeadlessException {
-        JFrame f = new JFrame(downloading + "...");
+     public static JDialog createDownloadIndicatorWindow(boolean undecorated) throws HeadlessException {
+        JDialog f = new JDialog((JFrame)null, downloading + "...");
         f.setUndecorated(undecorated);
         f.setIconImages(ImageResources.INSTANCE.getApplicationImages());
         f.getContentPane().setLayout(new GridBagLayout());
@@ -145,8 +145,8 @@
      */
     private static void placeFrameToLowerRight() throws HeadlessException {
        Rectangle bounds = ScreenFinder.getCurrentScreenSizeWithoutBounds();
-        frame.setLocation(bounds.width+bounds.x - frame.getWidth(),
-                bounds.height+bounds.y - frame.getHeight());
+        dialog.setLocation(bounds.width+bounds.x - dialog.getWidth(),
+                bounds.height+bounds.y - dialog.getHeight());
     }
 
     /**
@@ -160,14 +160,14 @@
 
         ActionListener hider = new ActionListener() {
             public void actionPerformed(ActionEvent evt) {
-                synchronized(frameMutex) {
-                    frame.getContentPane().remove((DownloadPanel) listener);
-                    frame.pack();
+                synchronized(dialogMutex) {
+                    dialog.getContentPane().remove((DownloadPanel) listener);
+                    dialog.pack();
 
-                    if (frame.getContentPane().getComponentCount() == 0) {
-                        frame.setVisible(false);
-                        frame.dispose();
-                        frame = null;
+                    if (dialog.getContentPane().getComponentCount() == 0) {
+                        dialog.setVisible(false);
+                        dialog.dispose();
+                        dialog = null;
                     }
                 }
             }
@@ -253,14 +253,14 @@
                 }
 
                 public void recreateFrame(boolean undecorated) throws HeadlessException {
-                    JFrame oldFrame = frame;
-                    frame = createDownloadIndicatorFrame(undecorated);
-                    frame.getContentPane().add(self, vertical);
-                    synchronized (frameMutex) {
-                        frame.pack();
+                    JDialog oldFrame = dialog;
+                    dialog = createDownloadIndicatorWindow(undecorated);
+                    dialog.getContentPane().add(self, vertical);
+                    synchronized (dialogMutex) {
+                        dialog.pack();
                         placeFrameToLowerRight();
                     }
-                    frame.setVisible(true);
+                    dialog.setVisible(true);
                     oldFrame.dispose();
                 }
             });
@@ -294,8 +294,8 @@
                     add(mainProgressPanel, verticalIndent);
                     state=States.COLLAPSED;
                 }
-                synchronized (frameMutex) {
-                    frame.pack();
+                synchronized (dialogMutex) {
+                    dialog.pack();
                     placeFrameToLowerRight();
                 }
 
@@ -333,7 +333,7 @@
             // each update.
             header.setText(downloading + " " + downloadName + ": " + percent + "% " + complete + ".");
             Container c = header.getParent();
-            //we need to adapt both panels and also frame to new length of header text
+            //we need to adapt both panels and also dialog to new length of header text
             while (c != null) {
                 c.invalidate();
                 c.validate();