Setting Colors in SWT

后端 未结 3 1587
南方客
南方客 2020-12-29 18:03

This is pretty simple, I come from a swing/awt background.

I\'m just wondering what the proper way to set the background color for a SWT widget is?

I\'ve bee

3条回答
  •  情歌与酒
    2020-12-29 18:29

    For standard colors (including common colors and default colors used by the operating system) Use Display.getSystemColor(int), and pass in the SWT.COLOR_* constant for the color you want.

    Display display = Display.getCurrent();
    Color blue = display.getSystemColor(SWT.COLOR_BLUE);
    Color listBackground = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
    

    Note that you do not need to dispose these colors because SWT created them.

提交回复
热议问题