JProgressBar and ObserverPattern in multiple document app??

Hi,
I'm working on a multiple document application with jInternalFrames. There is one very time-consuming process and therefore I'd like to show a progressbar for the user to know, that the programm is still running.
So Icreated a seperate internalFrame with a jProgressBar and I implemented the observer pattern.
Now the problem is: my time-consuming process (which is in the observable-class) notifies the internalFrame whenever one percent of work is done,
and the programm even enters the update method of the internal frame. In this update method i set the value of the
progress bar, but nothing happens. I tried a repaint() and even a paintImmediately() but nothing happens until
my time-consuming process is done. That's not exactly what i call a progressbar... ;-) It is even worse as the whole view of the application is faulty once I minimized and then resized the main window while my time-consuming process is running.
So I already found some articles and I fear I have to work with threads. But how?
can anyone explain to me what method I have to run as a thread and how can I refresh my internalFrame respectively the progressbar then?
I hope anyone can help me...

* Progress_Test.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Progress_Test extends JFrame {
    public Progress_Test() {
        initComponents();
    private void initComponents() {
        desktop = new JDesktopPane();
        internalFrame = new JInternalFrame();
        panel = new JPanel();
        progressBar = new JProgressBar();
        progressBar.setVisible(false);
        toolbar = new JToolBar();
        startBtn = new JButton();
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setTitle("Test Progress");
        internalFrame.setPreferredSize(new Dimension(200, 100));
        internalFrame.setVisible(true);
        panel.add(progressBar);
        internalFrame.getContentPane().add(panel, BorderLayout.CENTER);
        startBtn.setText("Start");
        startBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                startBtnActionPerformed(evt);
        toolbar.add(startBtn);
        internalFrame.getContentPane().add(toolbar, BorderLayout.NORTH);
        internalFrame.setBounds(0, 0, 200, 100);
        desktop.add(internalFrame, JLayeredPane.DEFAULT_LAYER);
        getContentPane().add(desktop, BorderLayout.CENTER);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-400)/2, (screenSize.height-300)/2, 400, 300);
    private void startBtnActionPerformed(ActionEvent evt) {
        if( ltThread == null || !ltThread.isAlive() ){
            progressBar.setValue(0);
            LongTask lt = new LongTask();
            ltThread = new Thread(lt);
            ltThread.start();
    public static void main(String args[]) {
        new Progress_Test().setVisible(true);
    private JDesktopPane desktop;
    private JInternalFrame internalFrame;
    private JPanel panel;
    private JProgressBar progressBar;
    private JButton startBtn;
    private JToolBar toolbar;
    private Thread ltThread;
    public class LongTask implements Runnable{
        public LongTask() {
            progressBar.setMaximum(max);
        public void run(){
            progressBar.setVisible(true);
            int n=0;
            while ( n<max ){
                n++;
                progressBar.setValue(n);
                try{Thread.sleep(1000);}catch(Exception ex){}
            progressBar.setVisible(false);
        private int max=10;
}

Similar Messages

  • Download Multiple Documents App from Solutions2Share

    Hello, I have downloaded the 'Download Multiple Documents App' from Solutions2Share and installed it on several existing site collections on my SharePoint online office 365 tenant. It works without any problems on all sites on all site collections apart
    from one....which is typically the site I need it to work most on.
    When I try to download multiple documents from a document library from this site I get directed to the download multiple documents page and I see the app trying to download the documents but then get message ''Could not retrieve list:Forbidden''
    This happens with every document library on the site. What is strange , when I do this on a document library on the top level site of the same site collection, i.e the default site that is created when creating a site collection - it works fine.
    I've gone through all the site settings and site features and cannot see what would be causing this! I am the Site Administrator and am in the Site Owner/Members permissions groups for this site. Tried it with different browser too.
    kegan1

    Hi,
    According to your error message, it says that the Download Multiple Documents App has permission issue for the list. You can contact [email protected] or go to knowledge base:
    http://wiki.solutions2share.net/category/products/download-muliple-documents/
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Opening multiple documents in pages

    There was a discussion of this last February, but I want to follow up and ask, again, is there any way to open and work back and forth between multiple documents in ipad 2 Pages? If I have 2 versions of a text, say 2 drafts of a book chapter, I need to be able to compare texts closely in order to copy, paste, and edit. This is very inconvenient if I have to constantly close one draft and then open the other. Is there any way to have the 2 drafts open simultaneously, side by side or stacked, or to move back and forth quickly between the 2 drafts?
    Thanks,
    Dousik

    This is not a way to open the actual documents side by side, but it is a possible solution to the situation of needing to match the layout of Document 1 to the layout of Document 2.
    1. Create an image file of Document 1. (Open Document 1 and take a screenshot.)
    2. Open Document 2.
    3. Under Tools/Document Setup, click +, then add image from camera roll of Document 1.
    4. Adjust image size to match document size. (Select image, then click and drag nodes to edge of document.)
    5. With image selected, click (paintbrush icon) Format/Style/Style Options/Opacity. Adjust Opacity down to around 30 percent (you can adjust to personal preference later after you see how it works for you.)
    6. Click Arrange (still under Format) and send image to the back, then Lock.
    7. Click Done.
    8. Now you can match sizes/fonts/style of background Document 1 while working in Document 2.
    9. When you are done, go back to document layout and unlock, then delete image of Document 1.
    I agree we still need the side by side view for copy and paste speed, but until Apple Developers come to the rescue for us, this could save a little time when matching layout of existing document. I hope this helps out in the mean time! :)

  • Web start and multiple documents

    I am working on a rich client application that I want to deploy via web-start. There is a requirement for it to present the multiple-document-interface. Each time I double-click on a file, web-start kicks off the application in what appears to be a new JVM (at least, a new javaw.exe appears in the process list under windows-XP).
    Can anyone suggest a way for each instance after the first to detect the first instance, and to delegate the file-name to the first instance?
    I would prefer to keep the interaction between the instances as hidden and localized as possible. I have seen this done in C++ using CreateMutex and SendMessage. It looks like it may be possible to do this with RMI, by having each instance attempt to connect to a server, and on failure become a server, but that leads to race conditions, and may allow communications that cross to other machines. Named pipes would have worked, but Java does not support them. Sockets would work, but I would have to reserve some port number (which one would be safe on all machines?) and I don't know how to ensure that the socket would not be visible to other machines.
    Regards,
    Danny

    The JNLP file can add a file assciation for an app., the [FileOpen/SaveService example|http://pscode.org/jws/api.html#fs] declares file type text/sleepytime.
    As to making sure it is one VM, or one instance, look to the SingleInstanceService.

  • How do you highlight multiple documents rapidly, rather than having to click on the document and on "command" one at a time?

    How do you highlight multiple documents rapidly, rather than having to click on the document and on "command" one at a time? Right now, when I'm trying to highlight documents to export, I have to click on each document individually. Is there a way to highlight one document while scrolling down the list until all desired documents are highlighted? I would like to rapidly be able to do this to save time when I am exporting or saving multiple files from my documents to an external drive, CD-Rom or cloud storage.

    Click on the first item
    Hold the Shift key
    Click on the Last Item.
    All the items in between will be selected.

  • Loading Apps and PDFs to multiple iPads with different Apple IDs

    Hello,
    We are deploying 200+ iPads to our business and we are configuring each of the devices individually on-sight. We have received each employee's Apple ID and password for these corporate devices.
    We want to load 7 free apps to each iPad and a variety of PDFs to iBooks before we deploy the devices. We have experimented with Apple Configurator for the Apps and iTunes for the PDFs and run into a few problems.
    Apps:
    When we loaded these 7 free apps using Apple Configurator from a Macbook Pro to an iPad with a different Apple ID, we had no problem. The iPad user was able to download other apps using their own Apple ID without any issues. The problem came when we tried to update these originally loaded apps. When the user is prompted to update, the Macbook Pro user's Apple ID showed up with the update and there was no way to get around that even though the device was logged into the iPad owner's Apple ID in the settings.
    Is there a way to push multiple apps from one device to another without have two different Apple IDs sitting on the one device?
    PDFs:
    A similar problem happened with iTunes and iBooks. When we pushed PDFs from the Macbook owner's iTunes to the iPad, there was no problem. When the iPad user tried to upload some of her own PDFs from her Apple ID in iTunes, the originally loaded PDFs were wiped.
    Is there a way for both sets of PDFs to stay on the device in iBooks without either getting wiped?

    I don't really have any solutions other than uploading the files to cloud storage such as drop box, google, or skydrive and then sharing them to all the users.
    You can try these links however:
    Mobile Device Management
    Amtelnet MDM
    http://www.amtelnet.com/mdm/mobile-device-management.php
    Meraki MDM
    http://www.meraki.com/products/systems-manager/
    Here's information regarding rolling out iOS devices across an organization, business or educational establishment:
    http://www.apple.com/support/ipad/enterprise/
    And here's about bulk app purchasing:
    http://www.apple.com/business/vpp/

  • I teach neuroanatomy and am looking for an app that would allow me to use a stylus on the iPad to label a wordforMac or powerpoint document.  Any suggestions?

    Help needed:  I teach neuroanatomy and am looking for an app that would allow me to use a stylus on the iPad screen to label diagrams in wordforMac or powerpoint format. Any suggestions?

    I don't believe it will open a Word document, but Writepad allows for handwritten conversion of notes to text and then to email. Might help you some of the way...

  • App-V PowerShell: Script to Query XenApp Servers for App-V Publishing Errors and Output an Excel Document with the Results

    Please Vote if you find this to be helpful!
    App-V PowerShell:  Script to Query XenApp Servers for App-V Publishing Errors and Output an Excel Document with the Results
    Just posted this to the wiki:
    http://social.technet.microsoft.com/wiki/contents/articles/25323.app-v-powershell-script-to-query-xenapp-servers-for-app-v-publishing-errors-and-output-an-excel-document-with-the-results.aspx

    Hi petro_jemes,
    Just a little claritification, you need to add the value to the variable "[string]$ou", and also change the language in the variable "$emailbody" in the function "Get-ADUserPasswordExpirationDate".
    I hope this helps.

  • Is there a way to sort a PDF file with multiple pages by a specific field within the PDF? All pages have the same invoice format and i would like to sort by a field within and then print the documents. (Vendor, PO

    Is there a way to sort a PDF file with multiple pages by a specific field within the PDF? All pages have the same invoice format and i would like to sort by a field within and then print the documents. (Vendor, PO#, Date, ect.)

    When you say field, do you mean specifically a form field, such as a text field? Or is the information regular text on the page?

  • On my ipad, is it possible to use stylus or fingers to copy and paste a specific area on a document, PDF., web page, etc... It would be great to pull specific areas out of a PDF. And paste into a note app I'm thinking of downloading.  Thank you.

    On my ipad, is it possible to use a stylus or fingers to draw out a specific area to copy and paste;  I'm looking to copy from a word document, PDF., web page, etc... It would be great to pull specific areas out of a PDF. And paste into a note app I'm thinking of downloading.  Thank you.

    Yes. I do it using Adobe Reader for PDF files, Pages for Word files, I can copy from Safari or iCab Mobile and paste into another app. I use my finger even though I do have a stylus. I rarely use my stylus anymore, but yes it's possible.

  • Best Way to Aggregate Multiple Announcement Apps and Possibly External RSS Feed

    Hello,
    I have two separate announcement apps (one in sub-site A, and one is sub-site B). I am trying to create a webpart that will display content from both apps together.
    I have tried to setup a CSWP and have been able to set the query to pull in the data (Although it shows expired announcements, which I would need to eliminate). Now, I am trying to customize the display of the CSWP, including the property mapping values
    to display the announcement title (currently working with the URL as a link) and body (truncated like the announcement summary view if possible).
    How can I get the body from the announcement to display? The 'body' field isn't listed as an option in the drop down list of mapping values. Do I need to toggle an option on the separate announcement apps, create a column, map a field, or some combination?
    Also, I'd like to know if it is possible to add in an external RSS feed. Or, if there is a completely different way to approach and accomplish this, please let me know.
    Thank you

    Hi,
    To display the “Body” field of Announcements list properly in Content Search Web Part, you can take a look at this blog about how to customize the display template for a good
    start:
    http://social.technet.microsoft.com/Forums/en-US/bf0eb4de-445f-435a-8c88-1826bfb3aae5/best-way-to-aggregate-multiple-announcement-apps-and-possibly-external-rss-feed?forum=sharepointdevelopment
    If there are more complex needs in customization, the two links below would be helpful:
    http://blogs.technet.com/b/sharepoint_quick_reads/archive/2013/09/03/3588171.aspx
    http://blogs.technet.com/b/tothesharepoint/archive/2013/05/28/stage-11-upload-and-apply-display-templates-to-the-content-search-web-part.aspx
    Also, if you have several questions, it is recommended to post them in each single thread to make others in this forum easier to focus on one issue in one thread.
    Best regards
    Patrick Liang
    TechNet Community Support

  • Recently my MacBookPro locked up on startup. Could not get past a certain point of progress bar. I had upgraded to Yosemite few weeks back, with no issues. I ended up doing a Recovery with Time Machine and I got all my apps, photos, documents, etc. back o

    Recently my MacBookPro locked up on startup. Could not get past a certain point of progress bar. I had upgraded to Yosemite few weeks back, with no issues. I ended up doing a Recovery with Time Machine and I got all my apps, photos, documents, etc. back okay --- except I got error messages that my "registration for Photoshop (I use CS4 Extended) and Photo Mechanic are no longer working".  I worked on Photoshop first, and tried (several times) to fix it with their online help suggestions.  Nothing worked.
    Is there a simpler way to "get my licenses/registrations back"???  I am also going to contact Camera Bits about the Photo Mechanic issues.   Thanks

    Same problem and for months now. I haven't been able to find a solution, but I suspect that's because I don't know exactly what's wrong.

  • When you open multiple documents, what's the rhyme and reason for the order the tabs are arranged?

    Hi, a student had a question and I honestly never thought about this: when you open multiple documents in Photoshop CS4, what's the rhyme and reason behind the order they're arranged in (left to right?). Sometimes they're in one order and sometimes they're in another, and it doesn't always correspond with the filenames or the order in which they were selected.
    Thanks, hope someone can enlighten us. It's probably really obvious, but... !

    My student says that's not exactly what she was asking. What she meant was, is the arrangement of multiple tabbed documents open within Photoshop (which one is furthest left, which one comes next to it, which one is furthest right etc) dependent on something? In what order they were opened, alphabetical, date created or what?

  • I have Pages 4.3 on my macbook and cannot open cloud documents without going to Pages 5; App store says it is already installed and I can't upgrade.  Suggestions please.

    I have Pages 4.3 on my macbook and cannot open cloud documents without going to Pages 5; App store says it is already installed and I can't upgrade.  Suggestions please.

    Have you looked in th Application folder for Page 5?

  • For the iOS5 (iTouch 4th Gen), was there supposed to be an iTunes and Documents app (directly on the iTouch) for the iCloud feature? Because I don't have it and I already tried restoring my iTouch again...

    For the iOS5 (iTouch 4th Gen), was there supposed to be an iTunes and Documents app (directly on the iTouch) for the iCloud feature? Because I don't have it and I already tried restoring my iTouch again...

    so now I have to close an account I've held for 5 years and lose all my content...... am I right?
    No.
    I suggest you contact iTunes support.
    -> http://www.apple.com/support/itunes/contact/
    and was declined because I didn't have enough funds. This is fine. This happens all the time. Its cash.
    I wouldn't say "this is fine" and it is not cash.
    In many places, attempting to use a debit card with no funds (even if you don't know there are no funds) is fraud and is illegal.

Maybe you are looking for