Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Control.setBackground(Color)

The change does not occur because the UI is not processing events until 
after you return.

You should either execute your "communicateWithServer" code in a separate 
thread and allow the UI thread to process events OR you can force the OS 
to process all outstanding Paint events using Control.update().  If you 
use Control.update() however, the UI will still be suspended so if for 
example, the user brings a window in front of your application and then 
removes the window, the area under the window will not be repainted again 
until after your "communicateWithServer" code terminates.  Therefore it 
would be much better to process your "communicateWithServer" code in a 
separate thread.  You can reset the label to blue using Display.asyncExec 
when your "communicateWithServer" code completes.

Veronika





"Erik Poupaert" <erik.poupaert@xxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx
02/17/2003 02:24 PM
Please respond to platform-swt-dev

 
        To:     <platform-swt-dev@xxxxxxxxxxx>
        cc: 
        Subject:        [platform-swt-dev] Control.setBackground(Color)



I've run into something strange with Control.setBackground(Color). I've 
got
one of these labels that should become green while the application is
communicating with the server, and turn back to blue, when the 
communication
is over (or red, if there was a problem).

//background is dark blue
label.setBackground(SWT.COLOR_GREEN);
communicateWithServer();
label.setBackground(SWT.COLOR_DARK_BLUE);

Now, the label never becomes green. It simply doesn't get executed. When I
change the text of the label, however, it does get executed. So, now I've
got the following strange workaround:

//background is dark blue
label.setBackground(SWT.COLOR_GREEN);
label.setText(label.getText()); //force repaint
communicateWithServer();
label.setBackground(SWT.COLOR_DARK_BLUE);


Is there any other, more appropriate, way to force a repaint?

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev





Back to the top