Modal dialogs


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Modal dialogs

  1. #1
    John Senford Guest

    Modal dialogs


    SUMMARY:
    Non-modal progress dialog does not get chance to be displayed fully before
    the comencement of the heavy processing that it should be displaying the
    progress for.


    DETAIL:
    OK, it's back to basics for a moment I'm affriad.

    I'm having a little trouble with a dialog class I've created, being that
    it never displays its contents.

    My class extends javax.swing.JDialog and is created and shown prior to some
    processing intensive stuff (file loading incidentally), during which I wish
    the contents of the dialog to be updated.

    The dialog window is painted to screen but unfortunately its contents (a
    JTextArea and a JProgressBar) do not get chance to be displayed if the dialog
    is set up to NOT be MODAL.

    If it IS set to be MODAL then the contents display fine, but of course, the
    processing that is to be carried out along side it is paused until the dialog
    is closed.

    Now understand that the dialog needs time to set up, and update, its display
    before passing back control to other processes and so I have tried littering
    the appropriate code with several strategically placed Thread.yield()'s and
    even Thread.sleep()'s...but to no avail.

    I am clearly missing some important code which I wondered if any kind soul
    could point out to me.

    thanks

    John

    PS
    please email any suggestions direct to me instead of/as well as posting to
    this forum

  2. #2
    Gerald Nunn Guest

    Re: Modal dialogs

    You need to run your heavy processing in a seperate thread and update the
    progress of processing in your dialog from that thread. Look for the
    SwingWorker class below on sun's site to do what you want.

    http://java.sun.com/products/jfc/tsc...ds/update.html

    Gerald



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center