Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [ve-dev] Setting colors, SWT lables


Hi Phillipe,

>label.setBackground(new Color(Display.getDefault(),200,111,50));

SWT requires explicit disposal of colors.  The color has to be either got from somewhere that manages it, like

setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));

or else we need to have code like

finao Color color = new Color(Display.getDefault(),200,111,50));
control.setBackground(color);
control.addDisposeListener(new DisposeListener(){
   public void widgetDisposed(Event e){
      color.dispose();
   }
});

or have instance variables for each color and dispose them with the view is closed down

Best regards,

Joe



"Philippe Ombredanne" <pombredanne@xxxxxxxxx>
Sent by: ve-dev-bounces@xxxxxxxxxxx

13/09/2007 16:17

Please respond to
pombredanne@xxxxxxxxx; Please respond to
Discussions people developing code for the Visual Editor project        <ve-dev@xxxxxxxxxxx>

To
"'Discussions people developing code for the Visual Editor project'" <ve-dev@xxxxxxxxxxx>
cc
Subject
RE: [ve-dev] Setting colors, SWT lables





Evi:
What about using  something like:
label.setBackground(new Color(Display.getDefault(),200,111,50));
Or keeping a tab on a dislpay in a variable?



--
Cheers
Philippe




-----Original Message-----
From: ve-dev-bounces@xxxxxxxxxxx [mailto:ve-dev-bounces@xxxxxxxxxxx] On
Behalf Of evi
Sent: Tuesday, September 11, 2007 4:23 AM
To: ve-dev@xxxxxxxxxxx
Subject: [ve-dev] Setting colors, SWT lables


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

_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev







Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU







Back to the top