我想像这样在 SWT 中画一个圆角矩形
我找不到这样做的方法,所以我决定扔掉我的代码并在这里问:(
有什么想法吗?
谢谢 :D
编辑
我又试了一次,这就是我现在所拥有的
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.wb.swt.SWTResourceManager;
public class TesteGradient extends Canvas {
Color COLOR_TOP = SWTResourceManager.getColor(166, 166, 166);
Color COLOR_BOTTOM = SWTResourceManager.getColor(241, 241, 241);
private boolean selected = false;
public TesteGradient(Composite parent, int style) {
super(parent, style);
this.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.setAntialias(SWT.ON);
e.gc.setBackground(COLOR_BOTTOM);
e.gc.setForeground(COLOR_TOP);
e.gc.fillGradientRectangle(0, 0,93, 27, true);
e.gc.setClipping(0, 0, 4, 4);
}
});
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
}