CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2000
    Posts
    6

    ProgressMonitor Dialog.

    Hi,

    I tried an example with progress monitor as given
    in 'Core Java' book. While the 'cancel' button is
    handled, the 'X' window closing button is not.

    If i 'Cut' the dialog, the background thread goes
    on and the status of the ProgressMonitor dialog
    is not 'canceled'.

    Any ideas how to handle the 'Cut' button.

    thanx,
    bhuvan.


  2. #2
    Join Date
    Mar 2000
    Location
    Dublin, Ireland
    Posts
    124

    Re: ProgressMonitor Dialog.

    Agniputhran,

    More information is needed about this ProgressMonitor Dialog you need help on.

    What do you want to do?
    Do you want to capture window-closing events?
    What do you mean when you say 'Cut the Dialog'?
    Is the ProgressMonitor not stopping when you try to kill the dialog?

    Regards,
    dogBear


  3. #3
    Join Date
    May 2000
    Posts
    6

    Re: ProgressMonitor Dialog.

    sorry. i got the naming wrong.

    I meant the dialog closing event.
    When i press the 'close dialog' with the 'X' button (as in windows),
    the dialog closes, but it is not asserted as anything.

    I want it to report a 'Cancel' operation even if the 'X' is used to close the dialog.

    If 'X' is pressed, the dialog is closed, but the background task goes on.

    regards.
    bhuvan.


  4. #4
    Join Date
    Mar 2000
    Location
    Dublin, Ireland
    Posts
    124

    Re: ProgressMonitor Dialog.

    Agniputhran,

    To recap:
    The Cancel button works perfectly but the Windows Kill button doesn't.

    Without the code you are using, I can only guess at this point.
    What I can tell you is that there is a "Window-closing" event that is fired whenever the window is dismissed. Whatever code you wrote that the Cancel button executes when pressed is the same code you want called when the "Window-closing" event is fired.

    To quickly help you with this problem, could you supply sample code and I'll show you what you need to do? It's the fastest way.

    Regards,
    dogBear


  5. #5
    Join Date
    May 2000
    Posts
    6

    Re: ProgressMonitor Dialog.

    Hi,

    Thats exactly what is happening. The Window close
    event is not handled properly.

    I need the window close event to work same as
    the handler for the 'cancel' button.

    I am using the javax.swing.ProgressMonitor class
    for doing this.

    Here is the code.


    ...
    Timer tim = new Timer ( 500, this );
    WorkerThread th = new WorkerThread();
    th.start();
    ProgressMonitor pm = new ProgressMonitor ( ... );
    tim.start();
    ...



    actionPerformed () // called by timer every 500ms
    {
    //get current state from thread.
    // update ProgressMonitor with current state.
    if ( pm.isCanceled() )
    {
    tim.stop(); // stop the timer which does checking.
    pm.close(); // close the dialog
    th.interrupt(); // stop the thread
    }
    }





    hope this helps.

    thanx,
    bhuvan.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured