Hello!
I have
tried to figure out how to set label background colors when working with Eclipse
SWT. The only advise I found was to use "label.setBackground(new
Color(display,200,111,50));
But in
automatically created VE+SWT construct "display" is not recognised. My code is
copied below, please advise what I need to change in order to set background
colors to widgets.
import
org.eclipse.swt.layout.GridLayout;
import
org.eclipse.swt.graphics.Point;
import
org.eclipse.swt.widgets.Shell;
import
org.eclipse.swt.widgets.Display;
import
org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import
org.eclipse.swt.graphics.*;
public class StartWindow {
private Shell sShell =
null;
private Label label = null;
public static void
main(String[] args) {
Display display =
Display.getDefault();
StartWindow thisClass = new
StartWindow();
thisClass.createSShell();
thisClass.sShell.open();
while
(!thisClass.sShell.isDisposed()) {
if
(!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
/**
* This method
initializes sShell
*/
private void createSShell()
{
sShell = new
Shell();
sShell.setText("Shell");
sShell.setSize(new
Point(300, 200));
sShell.setLayout(new
GridLayout());
label = new Label(sShell,
SWT.NONE);
label.setText("labellabellabel");
label.setBackground(new
Color(display,200,111,50));
}
}
Regards,
Evi