diff -r 204ef04cf29b progressbar/src/com/javafx/progressbar/ProgressManager.java --- a/progressbar/src/com/javafx/progressbar/ProgressManager.java Wed Jun 16 13:13:31 2010 -0700 +++ b/progressbar/src/com/javafx/progressbar/ProgressManager.java Fri Jun 18 14:16:42 2010 -0700 @@ -3,11 +3,13 @@ import java.applet.AppletStub; import java.awt.Color; import java.awt.Container; - +import java.awt.Point; import javax.jnlp.DownloadServiceListener; - import java.awt.event.ActionListener; import java.awt.event.ActionEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.MouseEvent; import java.awt.EventQueue; import java.awt.Insets; import java.net.URL; @@ -47,6 +49,7 @@ private static ProgressManager theInstance = null; private boolean needToHideOverlay = false; private int rescaleBound = -1; + private static Point point = new Point(); private ProgressBar progressBar; @@ -55,16 +58,30 @@ } public ProgressManager() { - Logger.info ("** Loading....JNLP Mode"); + Logger.info ("Loading....JNLP Mode"); theInstance = this; EventQueue.invokeLater(new Runnable() { public void run() { - frame = new JFrame(); + frame = new JFrame("Loading"); frame.setUndecorated(true); + frame.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + point.x = e.getX(); + point.y = e.getY(); + } + }); + + frame.addMouseMotionListener(new MouseMotionAdapter() { + public void mouseDragged(MouseEvent e) { + Point p = frame.getLocation(); + frame.setLocation(p.x + e.getX() - point.x, p.y + e.getY() - point.y); + } + }); + ImageIcon closeIcon = new ImageIcon("/images/close.png"); closeButton = new CloseButton (closeIcon) ; closeButton.addActionListener (ProgressManager.getInstance()); @@ -81,7 +98,6 @@ frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - closeButton.setLocation(frame.getWidth()-22,7); // place it at top right corner. //delay till first update event //frame.setVisible(true); } @@ -94,7 +110,6 @@ try { String appletid = this.stub.getParameter("deployJavaAppletID"); if (appletid != null && !"".equals(appletid)) { - Logger.info ("**** appletid: " + appletid); JSObject js = JSObject.getWindow(null); if (js != null) //js.call("hideOverlay", new Object[]{appletid}); @@ -110,12 +125,11 @@ public ProgressManager(final Object containerObject) { this(containerObject, null); - Logger.info ("***** Applet JNLP MODE..."); + //Logger.info ("Applet JNLP MODE..."); } public ProgressManager(final Object containerObject, final Object stub) { this.stub = (AppletStub) stub; - Logger.info ("***************"); theInstance = this; if (containerObject instanceof Container) { @@ -136,10 +150,14 @@ //Make sure we do this on EDT to prevent possible NPE and other issues public void run() { if (overallPercent < 100 && frame != null && !frame.isVisible()) { + closeButton.setLocation(frame.getWidth()-22,7); // place it at top right corner. + Logger.info ("overallPercent: " + overallPercent); frame.setVisible(true); } - progressBar.progress (rescale(overallPercent)); + int rescaledVal = rescale(overallPercent); + progressBar.progress (rescaledVal); + frame.setTitle (rescaledVal + "% Loading"); } }); } @@ -167,7 +185,7 @@ } public void done () { - Logger.info ("*** Completed"); + Logger.info ("Download Completed"); if (frame != null && frame.isVisible()) { EventQueue.invokeLater(new Runnable() { //Make sure we do this on EDT to prevent possible NPE and other issues @@ -184,6 +202,7 @@ done(); } + // u20 and older may pass initial overall value to be more than 01. // in that case, we need to rescale the progress. private int rescale(int overall) {