Article View: borland.public.jbuilder.java.language
Article #18282Re: Capturing events
From: Rich Downing
Date: Wed, 15 Jul 1998 00:00
Date: Wed, 15 Jul 1998 00:00
43 lines
2207 bytes
2207 bytes
Charles Montgomery <cmont@best.com> wrote: >I'm trying to capture a button click to cancel an >operation, >but the listener never fires. This isn't >surprising - in other languages you have to >manually check for windows messages from within >your loop (e.g. Application.ProcessMessages in >Delphi), but I can't find an analog in Java. I >tried creating another thread, but you have to >loop to stay in run() and the event doesn't fire >while you're in run(). > >How do you do this in java? I need to get the >multi-thread approach working regardless because >I'm also making JDBC calls and I need to let the >user cancel the query, which requires another >thread. It would also be nice to know if there's a >way to check for events within a single thread. > >Thanks The way I do this is as follows. The application is a 24x7 thingie which runs forever. When the user selects the start menu item I create a thread which is where all the work is done. When the user selects the stop menu item (or application close) I set a boolean bUserStoppedProcess = true, and put up a status display that the application will stop shortly. When the program is in a consistant state in my running thread I check to see if the boolean has been set, and if so, close databases, do some cleanup and return. Rich ---------------------------------------------------------------------- Richard V. Downing Work email: richard.downing@vsin.com Senior Software Engineer Home email: rvd@mindspring.com VideoConferencing Systems, Inc. Web: http://rvd.home.mindspring.com Norcross, Ga ------------ When surrounded by wolves 'tis best to howl -------------
Technical Details
Message-ID:
<35b2e161.12566158@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<35AC551E.C69558DD@best.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,fb36a8b8b5d13eb3 X-Google-Attributes: gidf74b3,public From: rvd@mindspring.com (Rich Downing) Subject: Re: Capturing events Date: 1998/07/15 Message-ID: <35b2e161.12566158@forums.borland.com> X-Deja-AN: 371736212 Content-Transfer-Encoding: 7bit References: <35AC551E.C69558DD@best.com> Content-Type: text/plain; charset=us-ascii Organization: mindspring.com Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language