gc.setAlpha(int alpha) alpha的范围为0-255
alpha越小,越透明。alpha值越大,表示越不透明
需要注意的是在使用这个特性时,需要设置gc.setAdvanced(true);
方法原型为
**
* Sets the receiver's alpha value which must be
* between 0 (transparent) and 255 (opaque).
* <p>
* This operation requires the operating system's advanced
* graphics subsystem which may not be available on some
* platforms.
* </p>
* @param alpha the alpha value
*
* @exception SWTException <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
* </ul>
*
* @see #getAdvanced
* @see #setAdvanced
*
* @since 3.1
*/
public void setAlpha(int alpha) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (data.gdipGraphics == 0 && (alpha & 0xFF) == 0xFF) return;
initGdip();
data.alpha = alpha & 0xFF;
data.state &= ~(BACKGROUND | FOREGROUND);
}