Article View: borland.public.jbuilder.java.language
Article #14809Help....Thread problem
From: Ofir Amitai
Date: Wed, 04 Aug 1999 00:00
Date: Wed, 04 Aug 1999 00:00
39 lines
1792 bytes
1792 bytes
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:
<7o9bbl$ole3@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,550fa71efaf22d37,start X-Google-Attributes: gidf74b3,public From: "Ofir Amitai" <amitay@econ.haifa.ac.il> Subject: Help....Thread problem Date: 1999/08/04 Message-ID: <7o9bbl$ole3@forums.borland.com> X-Deja-AN: 508750546 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Reply-To: "Ofir Amitai" <amitay@econ.haifa.ac.il> Newsgroups: borland.public.jbuilder.java.language