Article View: borland.public.jbuilder.java.language
Article #14732Re: Help....Thread problem
From: Marcel van den Dungen
Date: Thu, 05 Aug 1999 00:00
Date: Thu, 05 Aug 1999 00:00
49 lines
2043 bytes
2043 bytes
if the code that is executed in the thread is executed correctly like you said,
maybe there is no problem with the thread, but your button needs to be
repainted?
greetings
casper
Ofir Amitai wrote:
> Hi
>
> I wrote a Client Server applet.
> In this project after the client send a message by clicking the "send"
> button
> the button is disabled until the client gets a response from the server.
>
> I disabled the button using
>
> button.setEnabled(false);
> but when I did that the applet "froze " until the server sent the replay.
>
> so I used a separate thread to control the button enabled state:
> --------------------------------------------------------------------
> somewhere in the applet class:
> btnSend.setEnabled(false);
> ButtonHandler button = new ButtonHandler();
> button.start();
> ----------------------------------------------------------------------------
> The button calss:
> class ButtonHandler extends Thread {
> Applet1 myApplet = new Applet1();
>
> public void run() {
>
> while (myApplet.data[myApplet.friendTableRowNum][2] == null)
> try {
> sleep(500);
> } catch (InterruptedException ie) {}
> myApplet.requestFocus();
> myApplet.btnSend.setEnabled(true);
> myApplet.friendTableRowNum++;
> }
> }
>
> and here is my problem:
> When I debug the program I can see that the application performs the code
> but when I get back to the applet the button dosn't change the enabled to
> true.
Technical Details
Message-ID:
<37A99EB0.2485F9E2@c-content.nl>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7o9bbl$ole3@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,550fa71efaf22d37 X-Google-Attributes: gidf74b3,public From: Marcel van den Dungen <info@c-content.nl> Subject: Re: Help....Thread problem Date: 1999/08/05 Message-ID: <37A99EB0.2485F9E2@c-content.nl> X-Deja-AN: 509193164 Content-Transfer-Encoding: 7bit References: <7o9bbl$ole3@forums.borland.com> Organization: C-CONTENT b.v. Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language