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


This is a question that should be asked on the newsgroup so that people subscribed to swt-dev don't get spammed.

You can request a repaint by calling redraw(). However, if for some reason you decide to block the UI thread while communicating with a server (as the snippet suggests), then the repaint will not get dispatched until after your code finished executing.  You could force it by calling Control.update().

Why is it called redraw when it generates a PaintEvent?
Why do you drive on a parkway and park in a driveway?



"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