JProgressBar within the progress of a JProgressBar

Hello,
I'm looking to make a progress bar within the progress of another progress bar, is this possible? That is to say, I want to have a container that fills up to some level, then the "stuff" that filled it up itself fills with something else to another level. Right now I'm just drawing a box, then a somewhat shorter box within the first box, but I thought it might be neater with a JProgressBar or something like it. How would I go about using or extending JProgressBar to accomplish this effect.
Thank you.

Here's sort of a proof of concept. JProgressBar is a container, so you can add any component you want to it including another JProgressBar. Using GridBagLayout I made the smaller JProgressBar centered within the larger one. The smaller one also occupies 40% the width and 20% the height of the larger one. So if the larger one gets bigger (or smaller), the smaller progress bar will scale accordingly. The SwingWorker does my long task.
import javax.swing.*;
import java.util.List;
import java.util.Random;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
public class ProgressBarTest {
    public static void main(String[] args) {
       SwingUtilities.invokeLater(new Runnable() {
           public void run() {
               createAndShowGUI();
    private static void createAndShowGUI() {
        final JProgressBar outer = new JProgressBar();
        final JProgressBar inner = new JProgressBar();
        GridBagLayout layout = new GridBagLayout();
        outer.setLayout(layout);
        outer.add(new JLabel(),createConstraints(0, 0, 3, 1, 1.0, .4));
        outer.add(new JLabel(),createConstraints(0, 1, 1, 1, .30, .2));
        inner.setBorder(null);
        inner.setPreferredSize(new java.awt.Dimension());
        outer.add(inner, createConstraints(1, 1, 1, 1, .4, .2));
        outer.add(new JLabel(),createConstraints(2, 1, 1, 1, .30, .2));
        outer.add(new JLabel(),createConstraints(0, 2, 3, 1, 1.0, .4));
        SwingWorker worker = new SwingWorker<Void,Object>() {
            Random rn = new Random();
            @Override
            protected Void doInBackground() throws Exception {
                for(int i = 0; i < 100; i++) {
                    publish(outer,i);
                    for(int j = 0; j < 100; j += rn.nextInt(12)) {
                        publish(inner,j);
                        try{
                            Thread.sleep(10);
                        }catch(InterruptedException e) {
                            return null;
                return null;
            @Override
            protected void process(List<Object> chunks) {
                JProgressBar progressBar = (JProgressBar) chunks.get(0);
                int value = (Integer) chunks.get(1);
                progressBar.setValue(value);
            @Override
            protected void done() {
                outer.setValue(100);
                outer.removeAll();
        JFrame frame = new JFrame();
        frame.setContentPane(outer);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        worker.execute();
    private static GridBagConstraints createConstraints(
            int gridX, int gridY, int gridW, int gridH,
            double weightX, double weightY) {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = gridX; gbc.gridy = gridY;
        gbc.gridwidth = gridW; gbc.gridheight = gridH;
        gbc.weightx = weightX; gbc.weighty = weightY;
        gbc.fill = GridBagConstraints.BOTH;
        return gbc;
}

Similar Messages

  • Problem with the progress bar in swings

    Hi all,
    I need to show a progress bar till another window opens up in swings.Below is the code i used to show the progress bar.My problem is i am able to get the dialog box where i have set the progress bar but i cldnt get the progress bar.But after the specified delay,another window gets loaded.
    Plz tell me how to show a progress bar till another window loads.Any help is greatly appreciated :-)
                    //Show the progress bar till the AJScreens loads.
                    // Create a dialog that will display the progress.
                    final JDialog dlg = new JDialog(this, "Progress Dialog", true);
                    JProgressBar dpb = new JProgressBar();
                    dpb.setVisible(true);
                    dpb.setStringPainted(true);
                    dpb.setBounds(70,60,150,10);
                    dlg.getContentPane().setLayout(new BorderLayout());
                    dlg.getContentPane().add(BorderLayout.CENTER, dpb);
                    dlg.getContentPane().add(BorderLayout.NORTH, new JLabel("Progress..."));
                    dlg.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
                    dlg.setSize(300, 75);
                    dlg.setLocationRelativeTo(this);
                    // Create a new thread and call show within the thread.
                    Thread t = new Thread(new Runnable(){
                        public void run() {
    System.out.println("atleast comes here --->");
                            dlg.show();
                    // Start the thread so that the dialog will show.
    System.out.println("Gonna start the thread --> ");
                    t.start();
    System.out.println("Thread started --> ");
                    // Perform computation. Since the modal dialogs show() was called in
                    // a thread, the main thread is not blocked. We can continue with computation
                    // in the main thread.
                    for(int i =0; i<=100; i++) {
                        // Set the value that the dialog will display on the progressbar.
    System.out.println("i ----------> "+i);
                        dpb.setVisible(true);
                        dpb.setValue(i);
                        try {
                            Thread.sleep(25);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                    // Finished computation. Now hide the dialog. This will also stop the
                    // thread since the "run" method will return.
                    dlg.hide();regards,
    kani.

    Yeah i have tried that also.But no hope.
    My problem is am able to get the dialog box but not the progressbar,after the specified delay the dialog box goess off and the new window loads up.
    the progress bar is not getting displayed..that is my problem..
    can u plz help me out.

  • How to change the color of the progress bar and string

    Is their anyway to change the color of the progress bar and the string which shows the progress of the bar. The current color of the bar is purple and i would like it to be red or blue so that it stands out against the background of the JFrame i am using. I dont want to change the color of the JFrame
    Thanks in advance

    import java.awt.*;
    import javax.swing.*;
    public class ProgressEx {
        public static void main(String[] args) {
            UIManager.put("ProgressBar.background", Color.WHITE);
            UIManager.put("ProgressBar.foreground", Color.BLACK);
            UIManager.put("ProgressBar.selectionBackground", Color.YELLOW);
            UIManager.put("ProgressBar.selectionForeground", Color.RED);
            UIManager.put("ProgressBar.shadow", Color.GREEN);
            UIManager.put("ProgressBar.highlight", Color.BLUE);
            JFrame f = new JFrame("Test");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JProgressBar pb1 = new JProgressBar();
            pb1.setStringPainted(true);
            pb1.setValue(50);
            JProgressBar pb2 = new JProgressBar();
            pb2.setIndeterminate(true);
            Container cp = f.getContentPane();
            cp.add(pb1, BorderLayout.NORTH);
            cp.add(pb2, BorderLayout.SOUTH);
            f.pack();
            f.setVisible(true);
    }

  • Monitoring the Progress of a BufferedImageOp

    I just spent a couple of minutes figuring out how to do this and thought I might
    share it with anyone who's interested.
    Feel free to comment on, criticise, or improve on my approach.
    java.awt.image.BufferedImage sourceImage = ...;
    java.awt.image.BufferedImage targetImage = ...;
    targetImage.getSource().addConsumer(new java.awt.image.ImageConsumer() {
       private int pixelsDrawn = 0;
       public void setPixels(...) {
          // Update the number of pixels drawn so far:
          pixelsDrawn += width * height;
          // TODO: Tell other objects (e.g. a JProgressBar) about the update.
    java.awt.image.BufferedImageOp imageOp = ...;
    imageOp.filter(sourceImage, targetImage);NOTES:
    There are two setPixels() methods.
    Though it is not clear in the Javadoc, I assume only one will ever be called for
    a particular image source. Both still need to be implemented, however, on the
    assumption that you don't know which one will be called for this source.
    The Consumer seems to be notified one row at a time (with ConvolveOp, at least).

    hi
    I tried a similar approach, but i must tell you:
    1. usually one line is scanned in each setPixel say line 1, then line 2.....
    But for many filters these scanning is repeated several times, i.e. after all the lines has been scanned, the scanning is one again, i.e. line 1 is scanned again followed by the others. and this process is repeated 2-5 times depending on the filter.
    So i don't think we can get the progress the filter that way.
    If anyone got any good way to find the progress of a filter, please do let me know. my mailid is [email protected]
    Tanveer

  • Am I able to stream from sub folders within the VOD?

    Hi guys,
    I have Flash Media Server 3.5 on a Windows server, but I don't no much about how to make it work. Until know we have only used it for live streaming.
    I have let myself guide through the beginners pages and they're helpful, testing everything locally (applications/babyvultures/streams/_definst_/vultures.mp4).
    The problem is when I copy my project to the server; same structure, but no video. If I move the file to the applications/vod/media, and change the path in the script, there is no problems.
    So the big question is: am I able to have sub folders within the applications/vod ?
    The thing is, that I want to publish videos from different sites that is also located on the server, and what I thought I could do, was to make sub folders, one for each site and then people can access their streaming folder via FTP, being able to publish their own videos with the advantage of rtmp streaming.
    Is it a limit in FMS? Or is there a solution?
    Thank in advance

    My case is that I have FMS 3.5 (not FMIS) installed on a webserver with a bunch of sites who each have their videos, (some more than others).
    Right now they all publish their videos via each their site root or videos folder with progressive download, so to improve the viewers experience and to decrease the level uploaded Gb from the server, I want to use the FMS with RTMP streaming.
    On the webserver we have a few sites, who has a large quantity of videos and very long ones, and they need to have a sub folder structure to administrate their videos, so it could look like this:
    FMSroot/
            applications/
                         vod/
                             site1/
                                   folder1
                                   folder2
                                   folder3/
                                           subfolder1
                             site2/
                                   folder1
                                   folder2
                                   folder3/
                                           subfolder1
    I am not planning to make something very complicated with scipts and such. Just a Joomla site and a module where I type in the address of the videos.
    I have tested with Adobe Flash, and the beginners samples, to make a script that shows a video from applications/BabyVultures/streams/_definst_/, but I cannot make it work unless I place the video in the VOD.
    I have the same problem publishing videos thruogh a Joomla module - I cannot get access to the video.
    The funny thing is that, in the Flash Administration Console, it detects and accepts the request, but yet nothing happens.
    What is confusing is the MEDIA folder inside the VOD, but it is not part of the stream path name.
    What should be the path of the file: vod/subfolder/video.f4v or vod/media/subfolder/video.f4v or something else?
    Thanks in advance

  • The progress/time bar at top of the screen has disappeared

    On my Ipod Touch -- when playing a song -- the bar at the top of the screen (that shows how much total time there is for the song and where the player is within the song) has disappeared.  It was there yesterday, and now it's just gone.  BTW, the volume control is still there.  And otherwise, the player seems to be working fine.  Somewhere, I read that this situation might be resolved by re-syncing it.  I tried that and it didn't work.  Any idea as to what may have happened... and how can I fix it?

    In the music app play a song and when the song starts to play in the screen where the progress bar was tap in the middle of the screen and it should be back. I had this problem too but then i figured it out. And trust me if u do that it will be back. If that doesnt work tell me.

  • I cannot get my iWeb site to load onto my Godaddy domain. I can get it to test the connection but the progress circle never changes and it never loads.

    I cannot get my iWeb site to load onto my Godaddy domain.
    I can get it to test the connection succesfully but the progress circle never changes and it never loads.
    I know on my previous laptop and website when it was working it should a little progress circle where the little
    world icon sits. Now it doesn't load.

    'Publish to' should be set to FTP server
    Site name is the name you give to your site.
    Server address - the domain name of your site, e.g. fred.com
    User name - this is the specific user name for FTP which they gave you.
    Password - this is the password they gave you for FTP, not the password for your account.
    Directory/Path - leave blank to have an index.html file at root level and the site in a folder with its name, so that entering just the domain name takes you to the site. Or if you want it within a folder, enter the folder name.
    Protocol: FTP
    Website URL os the address which will reach your home page: if there is nothing in the Directory/Path field it will be just the domain name.

  • How to use multiple profiles within the same instance of Thunderbird

    About a month ago, I had Thunderbird configured with three profiles,
    and all three could be used within a single startup/instance of
    Thunderbird. That PC is now gone. I have re-configured the three
    profiles on a new PC, but am having trouble making all three
    useable within the same instance of Thunderbird. Can you help?
    Both PCs are/were Windows-7 64 bit.

    Thunderbird only opens on the default if one profile
    or
    if Profile Manager is instructed to ask at startup it will allow you to choose which Profile to open else it opens on the last Profile used..
    So it shows one Profile at a time in one instance of Thunderbird.
    However, one Profile can have many mail accounts.
    eg: I run 4 mail accounts in one Profile.

  • Is there a way to create a link within a document that will pull text from the document and open it up in a separate text box within the document?

    I am trying to link sections of an form within a PDF back to instructions within the same PDF document.  Instead of having this jump back to the page within the document I would like for it to pull up the identified text within a separate pop-up text box on the same page where the form lives.  Is this possible?

    Hi gwebster,
    Instead of linking back to the instructions page, may be you can use tool tips or comments so that the instructions can be seen besides the text.
    Regards,
    Rave

  • How easy is it to create a new add on? I would like to see tabbed display within the browser on FF24 on Android 4.2 – as per desktop FF

    Please excuse this if it's a noob Q – I am, indeed, completely new to Android. Tabbed display appears to have been possible on previous versions of FF for Android via several add ons but unfortunately no more. Display of each open tab within the browser – rather than the current arrangement with just the number in the corner – is still possible with FF desktop and also features in Chrome, Opera and Dolphin for Android. I would prefer not to use these other mobile browsers as FF outperforms them but I do need tabbed display to allow for PDF docs to open – using the PDF viewer add on – alongside their initiating webpage. Any ideas? Is it difficult to create an add on? What is the process? Is one in the pipeline? Many thanks in advance for any help or guidance you can offer...

    Many thanks for your reply, Waka – guess you're right that it's a new add on or bust... I still find it odd that such a common UI feature across mobile browsers is unavailable in FF24 either as an option under settings or as an add-on. Surely, I'm not the only person who finds this puzzling?

  • SSO for various applications within the same portal

    Is it possible to implement SSO at the application level in an EP 7.0 environment?
    Ex:  One Portal with ESS and BI Functionality (BI is connected to the BI backend, ESS is connected to the ECC backend, but all of it exists within the same portal instance) in which the BI Explorer would rely on SSO, while the ESS would require a logon to the portal.  The initial page of the portal would not be a logon screen, but rather a menu screen
    Does this functionality exist?

    For our purposes, ESS would have to be authenticated (perferably through Active Directory), while BI Explorer wouldn't require "visible" authentication, BUT the question would be, could all of this exist on the same portal..
    I agree that it certainly wouldn't be user friendly to ask users to logon (using AD l/p) for certain parts but not others.  I think the solution would simply to have 2 portal instances (ESS/ECC = Logon/Password,  BI Portal = SSO), and to federate the BI to the ECC Portal. That way, if someone wanted to work in BI and only BI, they could go without logging on, but if they wanted to go to the ESS Portal they would have to logon BUT would be able to use both ESS and BI.
    This all stems from an effort to eliminate the neccessity of having to logon to a portal (for a small group of managers), but still maintaining a level of security for ALL users in regards to employee self-service

  • Text wrap for a paragraph: How to define the width of a Text box /  active text area? I simply need a longish text to wrap within the frame!

    Hello, I've been searching for a good while in the forums now, but have found no solution or real mention of the problem – I hope some of you can help.
    I want to very simply layout a text between scenes, a slightly longer text that wraps within the frame margins. Here's an example of how I want it to look:
    Now, I couldn't for the life of me get the Custom Text to behave like that, as there are no parameters to set for the width of the text area. The Text Size, yes, along with the Tracking, Baseline and all that, but the width of the text box, no. The above was created by customizing one of the other Text Generator presets that happened to be left aligned.
    However, this preset has a fade in/fade out transition, which I do not want. There's no way to remove this transition as it seems integrated into the Text Generator (meaning they are not really presets, but separate kinds of Text objects? Very silly.)
    So I am asking you: Is there any way to get the Custom Text generator to behave like that? Just a text paragraph as above. Below you'll see all I can manage with the diffferent Custom Text parameters. Any kind of repositioning and resizing of the text just changes the position and size of the frame – but the actual text items are just cropped off where they extend out of that frame. Apparently the bounding box for the text is just some default length, and I can't find any way to adjust the width. See below my different attempts.
    The same text pasted into a Custom Text generator clearly extends outside the frame:
    Here Transform just moves – or resizes – the video frame that the Text Box exists inside:
    The Crop gives similar results, and of course Distort doesn't get me closer to what I need, either. There should be simply a Text Box Width parameter to set somewhere, but if it exists they have hidden it very well. How do you do it?
    Thanks for any help, this is a silly problem, but one of now many trivial problems that amount to me growing quite dissatisfied with FCPX. Hopefully I've just overlooked something.
    All the best,
    Thomas

    Thomas...same kind of crap here.
    I used Custom Text - entered a sentence, hit return, entered another.
    Set to 72 pt.
    The default alignment is centred - I want left aligned text...the text start point stays at the centre of frame and the sentence runs off the edge of the bounding box.
    There is no settings in the Text or Title inspector dialog to correct that!
    Using Transform will not sort it!

  • Student lost ability to audition loops within the loop browser

    Colleagues,
    My students were composing songs using GarageBand 3.0.4 in our Mac Lab.
    Two of my students showed me that, after they'd laid down three or four tracks by dragging loops into the main window, they could no longer get loops to play inside the loop browser. They would click on a loop, and nothing would happen.
    The loop would play once it was clicked and dragged into the window, but it would not play from inside the loop browser.
    Does anyone have any idea what my students might have done that could cause them to be unable to audition loops from within the loop browser?
    Thanks in advance for any insight you might be able to provide.
    Paul Daniels
    Pennridge Central MS
    144 North Walnut Street
    Perkasie, PA 18944

    Just drop them on the Loop Browser and the rest should be taken care of.

  • Creating Apple loops within the arrange window

    I have tried this before and had the same result again and again.
    I have a stereo recording of a drum kit at 120 bpm which I have chopped to a 2 bar cycle and want to turn it into an apple loop. to fit it into the song I am working on which is at 100 bpm.
    I select "add to apple loops library" from the Region drop down menu in the arrange window. the apple loops genre selection window opens which adds it to the apple loops browser. easy!
    But when I drop the loop back into the arrange window onto an Audio track within the same song which is 100bpm, it stays at the original tempo and doesn't snap to the bar. but still loops stretches and does what an apple loop should do but at the wrong tempo. what is that all about?

    with an extra note to my comment above
    if you've dropped the loop from the apple loop browser to the arrange window you then have to open it again in apple loop utility to sort it out by selecting "open in apple utility" from the Audio drop down menu on the arrange window which gives you a chance to edit it properly and now I have a decent loop. but then I have to save it again in the initial menu "add to apple loops" which I have to reclassify it again I thought it'd be a good idea to actually get rid of the first menu choice "add to apple loops" window and just have a window within logic which uses the same engine as apple loops utility and uses the same audio channel (the Last enabled channel in the Environment to Audition the loop because now when Apple loop utility opens the core Audio gets confused and comes out of my comuter speaker and then after a few cycles comes out of the Interface. I think there are too many "menu this", "loop utility that's" going on in logic. I do hope Logic 8 is going to trim away all the excess Lard which Logic has gained since mac took it off Emagic.

  • Creating a link to another sheet within the same file in Numbers

    I have a spreadsheet in Numbers that contains many detail sheets with a seperate Summary sheet.
    I want to be able to click on an entry (within a cell) in the summary sheet and (just like a hyperlink) it take me to the detail sheet of that name.
    There is a hyperlink option within the Inspector, but it is only to goto a url or email message.
    Can anyone help, or is this a request I should make for the next version?

    New features means new high version num.
    Version 1 for instance was updated as version 1.0.2 then 1.0.3
    At this time we just got the upgrade to version 2
    Some day we will get an update to version 2.0.2 with oddities corrections.
    Maybe later we will get an update to version 2.0.3 with other corrections.
    For new features we will have to wait for the upgrade to version 3 included in what I named NiWork '10.
    Prepare your bucks
    Yvan KOENIG (from FRANCE jeudi 5 février 2009 18:21:58)

Maybe you are looking for