0

Note: I have searched for hours going through hundreds of threads on multiple different sites but none of them are what i want to do. Couldn't even find some i could put together like a puzzle. Making a new class for it is something i prefer. If there is a better way to do it in the main class that would be nice :) Hope one of you can help me out.

My old download system opens a new window to download & it's just annoying & looks like crap.

What I want to do is add the Jprogressbar to my download system while it showing on the current jframe. Does anyone have source code or a link to a guide for this specific request?

I'm trying to add a better download manager w/ a jProgressBar in the middle of my screen. Once i figure out how to do that i can probably finish the rest of my idea on my own. Thanks to whoever can help me out :/

Example of my loading screen.

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
Ryan
  • 359
  • 2
  • 8
  • 15
  • An application launched using [Java Web Start](http://stackoverflow.com/tags/java-web-start/info) has access to the JNLP API that includes a [`DownloadService`](http://docs.oracle.com/javase/7/docs/technotes/guides/javaws/developersguide/examples.html#DownloadService) which in turn provides many features, include a download progress bar. – Andrew Thompson Sep 23 '13 at 05:17

1 Answers1

2

Take a look at How to use Progress Bars and just in case, Concurrency in Swing

And few examples of a SwingWorker and progress bar...

You could also try using a ProgressMonitor...for example...How create progress bar while file transfering

Community
  • 1
  • 1
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
  • 2
    See also *particularly* [`ProgressMonitorInputStream`](http://docs.oracle.com/javase/7/docs/api/javax/swing/ProgressMonitorInputStream.html), which is generally used with a [`ProgressMonitor`](http://docs.oracle.com/javase/7/docs/api/javax/swing/ProgressMonitor.html) as the UI component. – Andrew Thompson Sep 23 '13 at 05:23
  • Yes, it seems perfect for this situation, if the OP really wants to use their own download system (as opposed to the one provided by JWS for e.g.). I forgot when I wrote the comment, that the marvelous tutorial that you linked to explicitly covers them! But I bet our e.g. is better than theirs. ;) – Andrew Thompson Sep 23 '13 at 05:30
  • As for those link's you've supplied me with. I've read The tutorials on Oracle & I was only able to get a little closer to what i was trying to do. I'm not looking for someone to hand me the code, but just wanted to reply letting you know i've read those & still am confused. – Ryan Sep 23 '13 at 05:58
  • So I know how to get it to keep track of the file download, Just not getting how to draw it onto the jframe like you would an image ex: g.drawImage(300, 300); – Ryan Sep 23 '13 at 06:04
  • No. You would add it to the frame like any other component...The last `JProgressBar` is a nice simple example... – MadProgrammer Sep 23 '13 at 06:06
  • I'm still not getting what you're saying there. The last JProgressBar? the link you gave me? no where in any of those link does it show a coordinate drawing method. I want to be able to draw it anywhere on the screen using pixel coordinates. Sorry if i'm being frustrating btw. Not normally like this, but progress bars have been my struggle for the past few days. – Ryan Sep 23 '13 at 06:36
  • `JProgressBar` is just like any other Swing component (like `JLabel`). You add them to a container and Swing takes care of rest for you. Try taking a look through this [example](http://stackoverflow.com/questions/13846887/jprogressbar-too-fast/13846939#13846939) – MadProgrammer Sep 23 '13 at 06:38
  • What errors would it cause if it does? Because Game's like runescape & jethnisity have JProgressBars & i've look & private server's for both & a few have the bars moved around the screen. – Ryan Sep 23 '13 at 06:49
  • The most significant issue is know how big the progress bar should appear on the screen based on the users environment. What looks good on your screen may not look good on someone elses... – MadProgrammer Sep 23 '13 at 06:54
  • Yeah just to save you from ripping out your hair I'm just going to stick with my current loading screen & just have a % in text above my loading icon. Sorry for wasting your time. Rep++ – Ryan Sep 23 '13 at 06:56
  • [This](http://stackoverflow.com/questions/14802662/splash-screen-progress-bar-not-drawing/14803941#14803941) might be a bit closer to what you need...Not, paiting on a splash screen is a different process the painting a component, focus on the how the progress bar is painted, not how the splash screen is updated ;) – MadProgrammer Sep 23 '13 at 07:08
  • Do you have a skype i can send you a class in the chat & you can tell me if it's good? It work's but I'm good with c, c#, html, & css. still learning java so i don't know if it's clean. – Ryan Sep 23 '13 at 08:50